Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Indexers in c#?

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


Please Help Members By Posting Answers For Below Questions

Do loops in c#?

939


How to declare a property in a class?

1046


What is an inheritance in c#?

943


What is an xsd file?

965


How can you access a private method of a class?

1068


What is oledbconnection c#?

975


Can you instantiate an abstract class c#?

965


What are the Types of instancing properties and explain each. Explain the difference between multiuse,singleuse and globalmultiuse and which is default

1044


What is the difference between static and private constructor in c#?

1058


Explain partial class in c#?

962


Difference between call by value and call by reference in C#?

1059


How to open a new form on button click in Windows forms?

1012


What is difference between for and foreach in c#?

1046


Can we overload the main method in c#?

999


Explain how do you debug an asp.net web application?

957