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 / srinath thanuku

Sample code to use Indexers when there are more than one
variable in a Class.

class IndexerExample
{
private string[] SkillSet = new string[5];
private string userName;
private int salary;
public string this[int indexrange]
{
set
{
SkillSet[indexrange] = value;
}
get
{
return SkillSet[indexrange];
}
}
public int sal
{
get
{
return salary;
}
set
{
salary = value;
}
}
public string name
{
get
{
return userName;
}
set
{
userName = value;
}
}

}

Creating an Object of the Above Class:
IndexerExample obj = new IndexerExample();
obj[0] = "C#";
obj[1] = "VB.Net";
obj[2] = "ASP.Net";
obj[3] = "SQL Server 2005";
obj[4] = "JScript.Net";
obj.sal = 1000;
obj.name ="Madhavi K.";

Is This Answer Correct ?    14 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain manifest in c#.

893


What is a destructor in c#?

913


List down the commonly used types of exceptions in .net

839


Which function is the entry point for a DLL in MS Windows 3.1?

1095


Can you mark static constructor with access modifiers?

919


What is namespace in oops?

856


Define an array?

871


What is the difference between “finalize” and “finally” methods in c#?

876


What is a static in c#?

868


What do multicast delegates mean?

935


What is the base class from which all value types are derived?

884


Can we write class inside a class in c#?

896


What is a sealed class?

874


How we convert private assembly into public assembly?

898


What will a loop recorder show?

901