You can't do much to restrict the available types to int or string, but
if you are happy to allow any type:
public class Foo<T> {
public T Value {get;set;}
}
or in C# 2.0:
public class Foo<T> {
private T value;
public T Value {
get {return this.value;}
set {this.value = value;}
}
The only way to disallow other types would be to use a type inintializer
- but it probably isn't worth it. There are such things as generic
constraints, but none that would fit here.
Marc