Friday, 3 January 2014

C# Using indexers : GTK style

using System;
using Gtk;

namespace Lab2
{
class MainClass
{
public static void Main (string[] args)
{
int size=10;
HDFC emp=new HDFC(size);

emp[4]="Manish";
emp[7]="Divya";
emp[9]="Aarushi";

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

Console.ReadKey();
}
}
}


using System;
namespace Lab2
{
public class HDFC
{
private string[] Name;


public HDFC(int n){
Name=new string[n];
for(int i=0;i<n;i++)
{
Name[i]="null";
}
}

public string this [long index]
{
get{
return Name[index];
}
set{
Name[index]=value;
}

}
}
}


No comments:

Post a Comment