Answer Posted / srinivasu
1.Indexer is a concept of using an object like an array.
2.indexers are similar to properties
3.Indexer is a collection of SET and GET methods.
4.Indexer name must be "this".
5.One class can have only one indexer.
syntax:
------
properties:
-----------
string s;
public string Pname
{
set { s=value;}
get { return s;}
}
Indexers:(example)
---------
class test
{
string [] x=new string[3];
public string this [int i]
{
set {x[i]=value;}
get {return x[i];}
}
public void print()
{
for(int i=0;i<x.lenght;i++)
messageBox.show(x[i]);
}
}
//using
test t=new test();
t[0]="vasu";
t[1]="liki";
t[2]="kavi";
t.print();
| Is This Answer Correct ? | 16 Yes | 11 No |
Post New Answer View All Answers
What is the difference between an integer and int?
Explain about Serialize and MarshalByRef?
What is difference between singleordefault and firstordefault?
For read-only operation which property you have to designated?
What is difference between encapsulation and abstraction in c#?
Give an example to show for hiding base class methods?
Why do we use struct in c#?
What is multiple interface in c#?
What is xaml file in c#?
Can abstract class have constructor c#?
How do I do implement a trace and assert?
Give an example of a ctype.
What is difference between first and firstordefault?
What is difference between string and string builder?
Why do we use stringbuilder in c#?