![](/img/trans.png)
[英]CS1503 Argument1: cannot convert from 'string' to 'string[*,*]'
[英]CsvWriter, CS1503 Argument 2: cannot convert CultureInfo
我正在使用 CsvHelper(很棒的軟件包,感謝 Josh),並且在使用 CultureInfo 時遇到構造函數 with.Net Core 的問題。
喬什的例子有這樣的東西......(來自https://joshclose.github.io/CsvHelper/examples/writing/write-class-objects )
using (var writer = new StreamWriter("path\\to\\file.csv"))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteRecords(records);
}
但是,這給了我 CS1503 參數 2:無法從“System.Globalization.CultureInfo”轉換為“CsvHelper.Configuration.Configuration”
所以,我需要這樣做
using (var writer = new StreamWriter("path\\to\\file.csv"))
using (var csv = new CsvWriter(writer: writer ))
{
csv.Configuration.CultureInfo = CultureInfo.InvariantCulture ;
csv.WriteRecords(records);
}
喬什的例子是錯誤的還是我做錯了什么?
Josh 的示例適用於當前的 CsvHelper,版本 13.0.0
using (var writer = new StreamWriter("path\\to\\file.csv"))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteRecords(records);
}
在版本 13.0.0 之前,您的示例有效。
using (var writer = new StreamWriter("path\\to\\file.csv"))
using (var csv = new CsvWriter(writer))
{
csv.Configuration.CultureInfo = CultureInfo.InvariantCulture;
csv.WriteRecords(records);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.