c# - 如何解决错误 "Input string is not in correct format"

标签 c# string format

我正在用 c# 制作应用程序。在该应用程序中,我使用代码作为

 private void WriteCurrentData(HttpRequest request, TextWriter writer)
{
      Stream = Convert.ToString(objstream.m_StreamData[1]);
      writer.WriteLine(string.Format(Stream));
      writer.Flush();
}

其中 m_StreamData 是 ArrayList。 但有时我会收到错误

System.FormatException: Input string was not in correct format at System.Text.StringBuilder.AppendFormat() at System.String.Format()

请帮助我。提前致谢。

最佳答案

WriteLine() 中的 String.Format() 尝试(再次)解释该字符串。您已经将其转换为字符串,因此:

//writer.WriteLine(string.Format(Stream));
writer.WriteLine(Stream);

关于c# - 如何解决错误 "Input string is not in correct format",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9529498/

相关文章:

c# - 解析泛型时区分 ">>"和 ">"

c - 算法查找 2 个字符串中常见字符的数量

string - 一个 Unicode 字符占用多少字节?

java - Android:格式化字符串并添加粗体样式

python - 函数 def show_table 创建并返回表示二维表的格式化字符串

java - 将日期时间转换为字符串,时间错误

c# - 将 Entity Framework 对象绑定(bind)到 Datagridview C#

c# - 重命名类 Visual Studio 2017

c# - 如何在 C# 中使用定时器和事件?

javascript - 将一个字符串插入另一个字符串