首页 > 代码库 > string.Format中的BUG
string.Format中的BUG
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。