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