C#의 목록에 정수 값을 추가하려면 Add() 메서드를 사용하세요.
첫째, C#에서 정수 목록을 선언하십시오 -
List<int> list1 = new List<int>();
이제 정수 값을 추가하십시오 -
list1.Add(900); list1.Add(400); list1.Add(300);
전체 코드를 보자 -
예
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Demo {
public class Program {
public static void Main(String[] args) {
List<int> list1 = new List<int>();
list1.Add(900);
list1.Add(400);
list1.Add(300);
Console.WriteLine(list1.Count);
}
}
}