Indexer Methods - In its simplest form, an indexer is created using the this[] syntax. You can use intergers or even string to represent indexers. For e.g. following gives a function to represent using strings – public Person this [string name] {get {} set {}} We can also overload indexer methods , can have them on interfaces and also have multi dimensional arrays.
Operator Overloading- You can perform operator overloading . E.g Overloading an addition operator for a class point with two variables can be done–
public static Point operator + (Point p1, Point p2)
You can overload all kinds of operator’s unary, binary or comparison and other operators.
Custom Conversions - Also consider conversion between two classes which do not have a same parent. In order to perform this we can use either implicit or explicit conversion. Declare a explicit conversion using the following syntax-
public static explicit operator
public static implicit operator
Working with pointers - When you wish to work with pointers in C#, you must specifically declare a block of “unsafe code” using the unsafe keyword. Once you have established an unsafe context, you are then free to build pointers to data types using the * operator and obtain the address of said pointer using the ‘&’ operator.

0 comments:
Post a Comment