為什么我運行出錯
這是代碼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication9
{
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
??????????? string name;
??????????? Console.Write("請輸入您的姓名:");
??????????? name = Console.ReadLine();
??????????? Console.WriteLine("你好,{0]!",name);
??????? }
??? }
}
輸入名字回車后的結(jié)果
未經(jīng)處理的異常:? System.FormatException: 輸入字符串的格式不正確。
?? 在 System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
?? 在 System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
?? 在 System.IO.TextWriter.WriteLine(String format, Object arg0)
?? 在 System.IO.TextWriter.SyncTextWriter.WriteLine(String format, Object arg0)
?? 在 System.Console.WriteLine(String format, Object arg0)
?? 在 ConsoleApplication9.Program.Main(String[] args) 位置 e:\新建文件夾\代碼\ConsoleApplication9\ConsoleApplication9\Program.cs:行號 16
2018-07-21
?Console.WriteLine("你好,{0]!",name);應(yīng)該為? ??Console.WriteLine("你好,{0}!",name)