码迷,mamicode.com
首页 > 其他好文 > 详细

string.Format中的BUG

时间:2016-09-08 18:17:53      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

 public class Outer<T>
    {
        public class Inner<U, V>
        {
            static Inner()
            {
                System.Web.HttpContext.Current.Response.Write("<br>");
                System.Web.HttpContext.Current.Response.Write("Inner:");
                string t = typeof(T).Name;
                string u = typeof(U).Name;
                string v = typeof(V).Name;
                string str = string.Format("   Outer<{0}>.Inner<{1},{2}>  ", typeof(T).Name, typeof(U).Name, typeof(V).Name);
                System.Web.HttpContext.Current.Response.Write(str);
                System.Web.HttpContext.Current.Response.Write("<br>");
              
            }
            public static void DummyMethod()
            { 
             
            }
        }


    }
测试数据:
 Outer<int>.Inner<string, DateTime>.DummyMethod();
       Outer<string>.Inner<int, int>.DummyMethod();
       Outer<object>.Inner<string, object>.DummyMethod();
       Outer<string>.Inner<string, object>.DummyMethod();
       Outer<object>.Inner<object, string>.DummyMethod();
       Outer<string>.Inner<int, int>.DummyMethod();
结果:

  Inner: Outer.Inner

  Inner: Outer.Inner

  Inner: Outer.Inner

  Inner: Outer.Inner

  Inner: Outer.Inner

  实际要求结果:

   Inner: Outer<Int32>.Inner<String,DateTime>

  Inner: Outer<String>.Inner<Int32,Int32>

  Inner: Outer<Object>.Inner<String,Object>

  Inner: Outer<String>.Inner<String,Object>
  Inner: Outer<Object>.Inner<Object,String> 




 

string.Format中的BUG

标签:

原文地址:http://www.cnblogs.com/chquwa/p/5853717.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!