C#/Problems

5. 한 줄 출력시 ( Console.Write( ); ) 입력을 다음 줄로 넘기기, 마지막 쉼표 없애기

dev_sr 2020. 4. 21. 15:12

 

1. 코드

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Study_013_1
{
    class App
    {
        public App()
        {
            int length = 3;
 
            int j = 0;
 
            for(int i=0; i<length; i++)
            {
                if(j>=length-1)
                {
                    Console.Write("{0}", i);
                    Console.WriteLine();
                }
 
                else
                {
                    Console.Write("{0},",i);
                }
 
                j++;
                
            }
 
        }
 
    }
}
 
 

 

 

 

2. 결과값