The most common use of generic types is to create collection classes. There are some ones in c# such as list, hasttable, dictionary, array...
I have seen no diffirence between C# and Java as the following java example:
import java.util.*;
import java.io.*;
class pairtest1
{
public static ArrayList<String> a=new ArrayList<String>();
public static void main(String[] args)
{
Pair<String> mystring=new Pair<String>("Great");
}
}
class Pair<T>
{
T myvalue;
Pair(T in_value)
{
myvalue=in_value;
System.out.println("Pair inited type:" + myvalue);
}
}
Subscribe to:
Post Comments
(
Atom
)
0 comments:
Post a Comment