c# - 读取文件时出现 System.StackOverflowException c#
问题描述
我正在尝试将文件读入我的 wpf 程序,但 System.StackOverflowException 正在发生!任何帮助都会很棒,谢谢!!
我的代码:
private void BestSellerListtxt_TextChanged(object sender, TextChangedEventArgs e)
{
string[] TopFictionArray = File.ReadAllLines("TopFiction.txt");
string[] TopNonFictionArray = File.ReadAllLines("TopNonFiction.txt");
for (int i = 0; i < TopFictionArray.Length; i++)
{
BestSellerListtxt.Text = TopFictionArray[i];
}
BestSellerListtxt.Text = "";
for (int i = 0; i < TopNonFictionArray.Length; i++)
{
BestSellerListtxt.Text = TopNonFictionArray[i];
}
}
解决方案
试试这个,在 string.Join(Delimeter, array) 的帮助下,您可以在不使用循环的情况下连接数组元素,并且可以轻松打印
BestSellerListtxt.Text = string.Join("," , TopFictionArray);
BestSellerListtxt_TextChanged = strin.join("," , TopNonFictionArray);
推荐阅读
- json - 从 SQL Server NVARCHAR 列中提取 JSON 值
- android - Ionic 3 应用程序 - 如何使字体大小独立于本机设置?
- okhttp - 如何设置 OkHttp 来请求压缩资源而不是解压缩它们
- php - Laravel 不规则复数模型名称
- r - 了解 r 中 durbinWatsonTest() 的输出
- biztalk - 无法将绑定文件导入 Biztalk 管理控制台
- c# - 类型中的成员类型与 EF 中类型中的成员类型不兼容
- javascript - 在javascript中散列一个值 - 可以反转吗?
- javascript - 如何将 commonjs 模块添加到 Nuxt 项目?
- html - 产品页面 - 分屏滚动