麻烦能写一个例子吗
Console.Wirte()里面的string 格式是什么?

解决方案 »

  1.   

    Console.Wirte("我的变量是:{0}",变量)
      

  2.   

    你们误解我的意思了!!我要用sprintf输出到一个变量,不是输出到屏幕!!
    大哥!string test="我的变量是:{0}"
    Console.Wirte(test,"变量")不行!
      

  3.   

    你们误解我的意思了!!我要用sprintf输出到一个变量,不是输出到屏幕!!
    大哥!string test="我的变量是:{0}"
    Console.Wirte(test,"变量")
    test里的值还是"我的变量是:{0}"!!
      

  4.   

    用 String 类的 Format 静态方法: 
    ms-help://MS.VSCC/MS.MSDNVS.2052/cpref/html/frlrfSystemStringClassFormatTopic.htm如:
    string str = String.Format("The sum of {0} and {1} is {2}",2,3,2+3);
    将创建字符串"The sum of 2 and 3 is 5"。