我正在尝试在检查中合并多个错误消息,但有时会发现该站点丢失并且错误字符串不是空白。发生这种情况时,它将显示两个错误,但不会在新行上输出它。
这是一个例子...
根据代码应该说
不支持的日期格式为19/06/19。
网站丢失
以下是我的支票
private void FileCheck(string[] strArray, out string INum, out string IDate, out string site, out string errors)
{
INum = strArray[1];
IDate = strArray[2];
errors = "";
site = strArray[10];
string[] errorformats = {$"Unsupported date format of {IDate}.", "Site is missing"};
string[] format = {"MM/dd/yyyy", "M/dd/yyyy", "MM/d/yyyy", "M/d/yyyy"};
DateTime dateTime;
if (!DateTime.TryParseExact(IDate, format, CultureInfo.InvariantCulture,
DateTimeStyles.None, out dateTime))
errors = errorformats[0];
if (site == "" && errors != "")
errors = $"{errorformats[0]}{Environment.NewLine}{errorformats[1]}";
else if (site == "" && errors == "")
errors = errorformats[1];
}
我用下面的代码称呼它
using (var sr = new StreamReader(newFullPath))
{
while ((strbuild = sr.ReadLine()) != null)
{
var strArray = strbuild.Split('|');
string INum = string.Empty,
IDate = string.Empty,
site = string.Empty,
errors = string.Empty;
if (strArray[0] == "1")
{
FileCheck(strArray, out INum, out IDate, out site, out errors);
这是我的桌子的代码:
@if (Model != null)
{
<table class="table table-striped">
<!--Table Head-->
<thead>
<tr>
<th>Row</th>
<th>Invoice #</th>
</tr>
</thead>
<!--Table Body-->
<tbody>
@for (var i = 0; i < Model.Count(); i++)
{
<tr class="table-info">
<th scope="row">@i</th>
<td>@Model[i].InvoiceNumber </td>
<td>@Model[i].Errors </td>
</tr>
}
</tbody>
</table>
}
我曾经遇到过类似的问题,并且这种方法有效。试一试。
<td>@Html.Raw(Model[i].Errors) </td>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句