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
How many parameters can a method have c#?
What are some examples of desktop applications?
What is command object in c#?
What is the difference between c and c# programming?
Explain dataadapter.update method in .net?
Does c# support multiple class inheritance?
What is the difference between “dispose” and “finalize” variables in c#?
How do you set a class path?
What is data types in c#?
Can you access a hidden base class method in the derived class?
Can we customize the serialization process?
Explain metadata in c#.
Why do I get a "cs5001: does not have an entry point defined" error when compiling?
Is typeof c#?
Explain concurrency with aop?