Indexer
This is used to access the object like an array.Syntax: object[index]
When you use the above syntax, a field can be accessed.
Syntax for Indexer:
public datatype this[int index]
{
get
{
return arrayname[index];
}
set
{
arrayname[index] = value;
}
}
Download above code for Demo on Indexer : Download Links
Object Initializer
This concept is introduced in .NET Framework 3.0. This is used to initialize all the fields of an object, without using a constructor.Syntax:
Classname ObjectName = new Classname() { field1=value1, field2=value2, … };
No comments:
Post a Comment