Author Archives: compitionpoint - Page 26
Indexers
Indexers allow you to access an element of a private array or collection field. When you indicate an index for an instance of a class, indexers will get the right data…
Arrays for Classes
You can use arrays of objects. Creating arrays of objects is pretty much the same as when creating arrays for primitive data types such as int. For example, we can create…
Overloading Conversion Operators
You can overload the conversion behaviors in C#. For example, what if you want to convert one class into an unrelated class. We can overload the effect of casting or…
as Operator
You can use the as operator in C# to convert a class into another class within the same inheritance hierarchy. The as operator is equivalent to using casting with some minor differences as will…
Polymorphism
Polymorphism allows classes to transform into a different class within its inheritance hierarchy. It allows a programmer to use objects of different types but treat them in their “general” form while…
Partial Classes
Partial classes allows you to define a class in multiple seperate files. For example, you can place all the fields, properties, and constructors inside a file, and place all the methods…
Sealed Classes
Sealed class are classes that cannot be inherited by other class. Since sealed-classes cannot be inherited, they cannot be abstract. The following program shows an example of a sealed-class. namespace SealedClassesDemo…
Abstract Classes
Abstract classes are classes that always serves as base class for other classes. Abstract classes are slightly similar to interfaces but abstract classes can also have methods and properties that already…
C# Interface
C# Interfaces are similar to classes, but it only contains declarations for methods and properties. Interfaces can be considered as plugins to classes. The class that implements a particular interface is…
is Operator
The is operator in C# allows you to test if an object can be converted into another object mainly by using casting. The is operator requires two operands, the one that will be tested,…