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 to implement delegates in c#.net
Is c sharp free?
Is a c# interface the same as a c++ abstract class?
What is difference between class and abstract class in c#?
What is difference between constants and read-only?
What are virtual destructors?
What does typeof return c#?
what is IEquatable
Explain briefly the difference between value type and reference type?
What issues can be faced while delivering code?
How do I download a program to my desktop?
What is the difference between overriding and overloading in systemverilog?
Write a syntax for writing a event delegate.
What is private and shared assembly?
What is the role of the datareader class in ado.net connections?