Good Morning sir .....
I would like to break the program as well as the value of count
becomes less than 0......
but not successful to accomplish this task.
i have use function instead of property and exception habdling
techniche but the result is same
please help me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Generic4
{
class Program
{
static void Main(string[] args)
{
Employee<string> name = new Employee<string>();
Employee<int> age = new Employee<int>();
Employee<double> salary = new Employee<double>();
for (int i = 0; i < 10; i++)
{
Console.Write("Enter The Name Of The Employee---> ");
name.Value = Console.ReadLine();
Console.Write("Enter The Age Of The Employee----> ");
age.Value = Int32.Parse(Console.ReadLine());
Console.Write("Enter The Salary Of The Employee---->
");
salary.Value = Double.Parse(Console.ReadLine());
}
Console.Clear();
for (int i = 0; i < 10; i++)
{
Console.WriteLine("The Name OF Employee---> " +
name.Value);
Console.WriteLine("The Age Of The Employee---> " +
age.Value);
Console.WriteLine("The Salary Of The Employee---> " +
salary.Value);
Console.WriteLine();
}
}
}
public class Employee<T>
{
private T[] data = new T[10];
private static int count = 0;
public T Value
{
get
{
return this.data[--count];//This Line Have A Problem
}
set
{
this.data[count] = value;
count++;
}
}
}
}
Thanks Sir