Indexer in Csharp Example — C Sharp — ASP.Net Example
ASP.Net Example-Indexer in Csharp Example

Tuesday, April 26, 2011

Indexer in Csharp Example

The Indexer is also known as Smart Array.
Benefit with Indexer is that we not need to define Limit Value like Array.
Example Of Indexer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Indexer
{
class Tutorial
{
string [] name=new string[15];
public string this[int range]
{
set { name[range] = value; }
get { return name[range]; }
}
static void Main(string[] args)
{
Tutorial p = new Tutorial();
p[0] = "Mike";
p[1] = "Milan";
p[2] = "Vihar";
p[3] = "Vivek";
p[4] = "Sharad";
Console.Write(" {0} \n {1} \n {2} \n {3} \n {4}",p[0],p[1],p[2],p[3],p[4]);


Console.ReadLine();

}
}

No comments:

Post a Comment

ASPdotNET-Example