System.MissingMethodException:Method' StringBuilder.AppendFormat'未找到

时间:2017-05-29 03:41:16

标签: c#

我一直在跟随Derek Banas的教程,到目前为止它已经做得很好但是我无法正确使用StringBuilder。它表示,由于它的自动完成方法显然必须存在AppendFormat。

代码

using System;
using System.Globalization;
using System.Text;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            StringBuilder sb = new StringBuilder("Random Text");
            StringBuilder sb2 = new StringBuilder("This is some more Random Text", 256);

            Console.WriteLine("Capacity : {0}",
                              sb.Capacity);
            Console.WriteLine("Capacity : {0}",
                              sb2.Capacity);
            Console.WriteLine("Length : {0}",
                              sb.Length);
            sb2.AppendLine("\nMore important text!");

            CultureInfo enUS =
                CultureInfo.CreateSpecificCulture("en-US");
            string bestCust = "Bob Smith";
            sb2.AppendFormat(enUS, "Best Customer : {0}", bestCust);
            Console.WriteLine(sb2.ToString());

        }

    }
}

0 个答案:

没有答案