class test <T> where T : class
{
public void Write<T>()
{
Console.Write(typeof(T).FullName);
}
}
In the above class, it is possible to pass in a string for the class (test<string> Test = new test<string>
) and then int for the method? If so, what is the output? If not, what problems does this cause? I haven't actually tried this, despite using generics (in my own classes) and generic collections, frequently.
The way I write/see generic classes is as follows:
class <T> where T : class
{
public T Write()
{
Console.Write(T.ToString());
}
}