C#/C#200제

    [C#] 4일차 ( try~catch문, 각종 연산자 )

    18. DivideByZeroException과 try~catch문 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A018_DivideByZero { class Program { static void Main(string[] args) { int x = 10, y = 0; Console.WriteLine(10.0 / y); Console.WriteLine(x / y); } } } 10.0 / y 는 실수를 0 으로 나누기때문에 무한을 출력 x / y를 할때 y값이 0 이기 때문에 0으로 나눔 예외가 발생 Try~Catch 문으로..

    [C#] 3일차 ( Format과 연산자 처리)

    11. 형식지정자를 사용한는 String.Format()과 ToString using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A011_FormatSpecifier { class Program { static void Main(string[] args) { Console.WriteLine("{0:N2}", 1234.5678); Console.WriteLine("{0:D8}", 1234); Console.WriteLine("{0:F3}", 1234.56); Console.WriteLine("{0:8}", 1234); Console.Wr..

    [C#] 2일차 (변수 선언 및 자료형, Console.WriteLine메소드)

    4. 변수 선언 및 자료형 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A004_Variable { class Program { static void Main(string[] args) { Console.Write("이름을 입력하세요 : "); string name = Console.ReadLine(); Console.Write("나이를 입력하세요 : "); int age = int.Parse(Console.ReadLine()); Console.Write("키를 입력하세요 : "); float height = float.Par..

    [C#] 1일차 (간단한 C#컴파일, 프로젝트만들기, 입출력)

    1. 간단한 C# 컴파일 class Hello { static void main() { System.Console.WriteLine("Hello, World!"); } } C#은 class가 프로그램의 기본단위이다. 따라서 필드나 메소드등의 프로그램 구성요소들은 반드시 class 안에 존재해야한다. 2. namespace using System; namespace A002_HelloWorld { class Program { static void Main() { Console.WriteLine("Hello, World!"); } } } namespace는 프로젝트의 이름을 의미함 3. 콘솔에서 읽고 쓰기 using System; namespace A003_Console { class Program { st..