[英]How can I get the name only to show in the MessageBox using C# windows form .NET framework?
我已經有一個包含名稱和 id 的類,並且我也在使用列表方法並包括每個學生的名稱和 id。我還從組合框中選擇一門課程,並從包含名稱的列表框中選擇一個索引和身份證。 i.Name 正在生成錯誤,我也嘗試過編寫 All students.SelectedItem 而不是 i.Name (這有效,但它顯示了名稱和 id )下面附加的是那個 [![在此處輸入圖像描述][ 1]][1] 這是我下面的代碼
if (comboBox1.SelectedIndex != -1 && Allstudents.SelectedIndex != -1)
{
var query3 = from i in prod
where i == Allstudents.SelectedItem
select i.Name;
foreach(var i in query3)
{
var b = query3 ;
}
MessageBox.Show("The student" + i.Name +
"Has registered in the course" + comboBox1.SelectedItem);
我怎樣才能只顯示名字? [1]: https ://i.stack.imgur.com/ehQ6K.png
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.