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
Do loops in c#?
How to declare a property in a class?
What is an inheritance in c#?
What is an xsd file?
How can you access a private method of a class?
What is oledbconnection c#?
Can you instantiate an abstract class c#?
What are the Types of instancing properties and explain each. Explain the difference between multiuse,singleuse and globalmultiuse and which is default
What is the difference between static and private constructor in c#?
Explain partial class in c#?
Difference between call by value and call by reference in C#?
How to open a new form on button click in Windows forms?
What is difference between for and foreach in c#?
Can we overload the main method in c#?
Explain how do you debug an asp.net web application?