第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將 List<int> 作為 List<T> 對象訪問?

如何將 List<int> 作為 List<T> 對象訪問?

C#
守著一只汪 2021-08-22 15:16:01
為 newb 問題道歉,但我很難思考如何訪問通用列表中的整數(shù)列表,然后將所有這些信息顯示到列表視圖 (winform) 中。這是我到目前為止...    }    List<Student> students;    public class Student    {        public string First { get; set; }        public string Last { get; set; }        public List<int> Scores { get; set; }        public int ID { get; set; }        public string[] ToListViewItem()        {            return new string[] {                First,                Last,                ID.ToString(),                Scores.ToString()            };        }    }    protected override void OnLoad(EventArgs e)    {        base.OnLoad(e);        students = new List<Student>        {        new Student {First="Svetlana", Last="Omelchenko", ID=111, Scores= new List<int> {97, 92, 81, 60}},        new Student {First="Claire", Last="O’Donnell", ID=112, Scores= new List<int> {75, 84, 91, 39}},        new Student {First="Sven", Last="Mortensen", ID=113, Scores= new List<int> {88, 94, 65, 91}},        new Student {First="Cesar", Last="Garcia", ID=114, Scores= new List<int> {97, 89, 85, 82}},        new Student {First="Debra", Last="Garcia", ID=115, Scores= new List<int> {35, 72, 91, 70}},        new Student {First="Fadi", Last="Fakhouri", ID=116, Scores= new List<int> {99, 86, 90, 94}},        new Student {First="Hanying", Last="Feng", ID=117, Scores= new List<int> {93, 92, 80, 87}},        new Student {First="Hugo", Last="Garcia", ID=118, Scores= new List<int> {92, 90, 83, 78}},        new Student {First="Lance", Last="Tucker", ID=119, Scores= new List<int> {68, 79, 88, 92}},        new Student {First="Terry", Last="Adams", ID=120, Scores= new List<int> {99, 82, 81, 79}},        new Student {First="Eugene", Last="Zabokritski", ID=121, Scores= new List<int> {96, 85, 91, 60}},        new Student {First="Michael", Last="Tucker", ID=122, Scores= new List<int> {94, 92, 91, 91} }    };到目前為止,我能夠讓我的列表視圖的前三列填充姓名和學(xué)生 ID,但我在最后一列中得到的只是“Systems.Collections.Generic...”等。
查看完整描述

2 回答

?
慕碼人8056858

TA貢獻1803條經(jīng)驗 獲得超6個贊

您可能正在使用Scores.ToString()返回類名的方法。你可以試試:string.Join(", ", Scores)相反。這將連接所有以,.分隔的值。


public string[] ToListViewItem()

{

    return new string[] {

        First,

        Last,

        ID.ToString(),

        string.Join(", ", Scores)

    };

}


查看完整回答
反對 回復(fù) 2021-08-22
?
陪伴而非守候

TA貢獻1757條經(jīng)驗 獲得超8個贊

這就是Scores.ToString()返回。

如果要顯示有用的信息,則需要編寫使用您的List<int>并返回有用信息的代碼。

從查看開始string.Join()。


查看完整回答
反對 回復(fù) 2021-08-22
  • 2 回答
  • 0 關(guān)注
  • 252 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號