亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

c#中List<int>是什么意思怎么用啊

c#中List<int>是什么意思怎么用啊

悶a 2017-11-06 20:17:38
List<int> arr = new List<int>();? ? ? ? ? ? int num;? ? ? ? ? ? do? ? ? ? ? ? {? ? ? ? ? ? ? ? Console.Write("輸入一個正整數:");? ? ? ? ? ? ? ? num = Convert.ToInt32(Console.ReadLine());? ? ? ? ? ? ? ? if (num <= 0)? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? Console.WriteLine("輸入錯誤!");? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? Console.WriteLine();? ? ? ? ? ? } while (num <= 0);? ? ? ? ? ? Console.Write("正整數{0}對應的二進制", num);? ? ? ? ? ? do? ? ? ? ? ? {? ? ? ? ? ? ? ? arr.Add(num % 2);? ? ? ? ? ? ? ? num /= 2;? ? ? ? ? ? } while (num > 0);? ? ? ? ? ? for (int i = arr.Count - 1; i >= 0; i--)? ? ? ? ? ? {? ? ? ? ? ? ? ? Console.Write("{0}",arr[i]);? ? ? ? ? ? }? ? ? ? ? ? Console.WriteLine();? ? ? ? ? ? Console.ReadLine();? ? ? ? }還有?arr.Add(num % 2);是和List<int>搭配的用嗎?
查看完整描述

1 回答

已采納
?
萬飛

TA貢獻117條經驗 獲得超186個贊

LIst<int> list=new List<int>();

<int>就是規定了這個數組添加的類型必須都是int,避免了裝箱拆箱;

list.add(1);就是往數組里面添加一個為1的 值

查看完整回答
2 反對 回復 2017-11-06
  • 悶a
    悶a
    count是不是和了length
  • 悶a
    悶a
    count是不是和length是一樣的作用。。。打錯了
  • 萬飛
    萬飛
    對的都是數值的元素的個數
  • 1 回答
  • 0 關注
  • 5810 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號