1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace Generic2
{
class Class1 <T>
{
private T _value;
public T Value
{
get { return _value; }
set { _value = value; }
}
public Class1(T value)
{
_value = value;
}
public override String ToString()
{
return _value.ToString();
}
public override Int32 Conv_int(T value)
{
Int32 val = Convert.ToInt32(value);
return val;
}
public override Double Conv_double(T value)
{
Double val = Convert.ToDouble(value);
return val;
}
}
class Program
{
static void Main(string[] args)
{
Class1<Int32> i = new Class1<Int32>(3);
i.Add(new Class1<Int32>(2));
foreach (Class1 j in this)
Console.WriteLine(j);
Console.ReadLine();
}
}
} |