본문 바로가기

프로그래밍/C#

C# 문자->숫자

static void Main(string[] args)
{
StreamReader file = new StreamReader("numbers.txt");

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

while (!file.EndOfStream)
{
string s = file.ReadLine();
list.Add(Int32.Parse(s));
}

Console.WriteLine("===== 정렬 전 =====");
for(int i=0;i<list.Count;i++) {
Console.Write(list[i]+ ": ");
}
Console.WriteLine("\n\n===== 정렬 후 =====");
list.Sort();
for (int i = 0; i < list.Count; i++)
{
Console.Write(list[i] + ": ");
}
Console.WriteLine("\n");
}

반응형

'프로그래밍 > C#' 카테고리의 다른 글

client 다른 버전  (0) 2019.08.29
server 다른 버전  (0) 2019.08.29
C# 문자열->시간  (0) 2019.03.24
C# 역문자열  (0) 2019.03.24
C# 문자열, 숫자, 영어 검사  (0) 2019.03.24