问题如下。
public Class A<T>
{
  //得到类型T的字符串。比如T为string形,得到一个字符串为"string",T为我自己定义的player类形,得到字符串"Player"
  public static string getstring()
  {
     string mystring="";
     mystring=??         //如何写呀。我看了半天的书没明白。
    
   }
}
链接地址:
http://community.csdn.net/Expert/topic/5449/5449447.xml?temp=.4896204
fxqyyzg(海冬青)(昨夜西风凋碧树。独上高楼,望尽天涯路)好像理解错了。

解决方案 »

  1.   

    public class A<T>
    {
      string myString;
    }
    我想得到一个字符串,这个字符串是由T决定的,比如T的类型为string,那么这个字符串为"string"。T的类型为int,那么这个字符串为"int"
      

  2.   

    T myString
    你书没看明白哦.
      

  3.   

    class Program
        {        static void Main(string[] args)
            {            A<string>.PrintMyType();
                Console.Read();
            }
           
        }
        class A<T> { 
            public static void PrintMyType(){
                Console.WriteLine(typeof(T));
            }
        }
      

  4.   

    typeof(T)是得到一个Type的实例,你要怎么做都可以~~~
      

  5.   

    熟悉一下Type类型,有很多有用的方法~~`