c#中Console.Writeline()两种使用方式的不同?

dongge2010 dongge2010 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
char[] trimChars = { ' ', 'e', 's' };
string userResponse = Console.ReadLine();
userResponse = userResponse.ToLower();
userResponse = userResponse.Trim(trimChars);
Console.WriteLine("The string is "+ userResponse);
if (userResponse == "y")
{
Console.WriteLine("It inlude the special char");
}
其中Console.WriteLine("The string is "+ userResponse);这句如果采用Console.WriteLine("The string is {0}", userResponse);就会出现异常这是什么原因?
...全文
评论 4
收藏 已收藏
分享
返回顶部
dongge2010
C# 111,128 成员 642,536 内容