using System;
namespace ConsoleApplication1
{
class student
{
private string[] name = new string[100];
public string this[int index]
{
get
{
return name[index];
}
set
{
name[index] = value;
}
}
public string this[char firstletter]
{
get
{
return name[firstletter];
}
set
{
name[firstletter] = value;
}
}
}
class Class1
{ static void Main(string[] args)
{
student s = new student();
s[0] = "uttam";
s[1] = "pathak";
Console.WriteLine(s[0] + " " + s[1]);
student s2 = new student();
s2['S'] = "uttam";
s2['M'] = "pathak";
Console.WriteLine(s2['S'] + " " + s2['M']);
Console.ReadLine();}}}
namespace ConsoleApplication1
{
class student
{
private string[] name = new string[100];
public string this[int index]
{
get
{
return name[index];
}
set
{
name[index] = value;
}
}
public string this[char firstletter]
{
get
{
return name[firstletter];
}
set
{
name[firstletter] = value;
}
}
}
class Class1
{ static void Main(string[] args)
{
student s = new student();
s[0] = "uttam";
s[1] = "pathak";
Console.WriteLine(s[0] + " " + s[1]);
student s2 = new student();
s2['S'] = "uttam";
s2['M'] = "pathak";
Console.WriteLine(s2['S'] + " " + s2['M']);
Console.ReadLine();}}}
No comments:
Post a Comment