Question1# 执行下面的代码时,它给了我一个格式错误。 System.double不能转换成System.string。获取格式错误,无法将system.double转换为system.string
var PiePriorityCount = dt.AsEnumerable()
.GroupBy(item => item.Field<string>("Priority"))
.Select(item => new { Priority = item.Key, TicketCount = item.Count() });
dtPriorityCount.Columns.Add("Priority", typeof(string));
dtPriorityCount.Columns.Add("Count", typeof(int));
lblStatus.Visible = true;
foreach (var itm in PiePriorityCount)
{
//lblStatus.Text = "Z" + "->" + itm.TicketCount;
DataRow dr = dtPriorityCount.NewRow();
dr["Priority"] = "P" + " " +itm.Priority;
dr["Count"] = itm.TicketCount;
dtPriorityCount.Rows.Add(dr);
}
在执行上面的代码它给我一个格式错误。 System.double不能转换成System.string。
问题2#得到的答案 在斯汀,LOG,包含在第一行的现状与第二行国有集团和第三组分配。所以我希望子字符串处于After状态直到行尾。即分配(1)
它们可以按顺序洗牌。没有必要,第一个将是状态,它可以是拥有组或分配组。
string LOG = "Status: Assigned (1) \n Owned Group: Jitesh - poiuyt \n Assigned Group: Jitesh - QWERTY";
string tb = "Status: ";
string tb1 = "Assigned Group: ";
int lenght = tb.Length;
int a = LOG.IndexOf(tb) + lenght;
int lenght1 = tb1.Length;
int a1 = LOG.IndexOf(tb1) + lenght1;
var status = LOG.Substring(a,'\n');
var status1 = LOG.Substring(a1, '\n');
预期输出:
状态=指派(1)
STATUS1 = Jitesh - QWERTY
电流输出:
状态=指派(
STATUS1 = Jitesh - Q
这是我所期待的,这就是我所得到的。
考虑选择一个更有意义的话题。 – C4u
Did not got you? –
这只是令人困惑。不能得到最后一句话。请展示如何在没有任何评论的情况下输出结果。你的评论和应该属于输出的部分之间有一点区别。 – C4u