C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » C# Syntax »

Indexer in C#


Posted Date: 20 Nov 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: SanthiMember Level: Gold    
Rating: 1 out of 5Points: 3



using System;
class IntIndexer
{
private string[] myData;

public IntIndexer(int size)
{
myData = new string[size];

for (int i=0; i < size; i++)
{
myData[i] = "empty";
}
}

public string this[int p]
{
get
{
return myData[p];
}
set
{
myData[p] = value;
}
}

static void Main(string[] args)
{
int size = 10;

IntIndexer myIndex = new IntIndexer(size);

myIndex[9] = "Some Value";
myIndex[3] = "Another Value";
myIndex[5] = "Any Value";

Console.WriteLine("\nOutput:\n");

for (int i=0; i < size; i++)
{
Console.WriteLine("myIndex[{0}]: {1}", i, myIndex[i]);
}
}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Indexer  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Hot to import data set to a CSV file
Previous Resource: Programmatically Download File from Remote Location to User Through Server
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use