목록언어/이것이 C#이다 (8)
Vienna
1. 실습_ArraySample using System; namespace _10장_ArraySample_359page { class Program { static void Main(string[] args) { int[] scores = new int[5]; scores[0] = 80; scores[1] = 74; scores[2] = 81; scores[3] = 90; scores[4] = 34; foreach (int score in scores) Console.WriteLine(score); int sum = 0; foreach (int score in scores) sum += score; int avg = sum / scores.Length; Console.WriteLine($"Average ..
1. 실습_Property using System; namespace _9장_Property_326page { class BirthdayInfo { private string name; private DateTime birthday; public string Name { get { return name; } set { name = value; } } public DateTime Birthday { get { return birthday; } set { birthday = value; } } public int Age { get { return new DateTime(DateTime.Now.Subtract(birthday).Ticks).Year; } } } class Program { static void..
1. 실습_Interface using System; using System.IO; using Interface; namespace Interface { interface ILogger { void WriteLog(string message); } class ConsoleLogger : ILogger { public void WriteLog(string message) { Console.WriteLine( "{0} {1}", DateTime.Now.ToLocalTime(), message); } } class FileLogger : ILogger { private StreamWriter writer; public FileLogger(string path) { writer = File.CreateText(..
1. 실습_BasicClass using System; namespace _7장_BasicClass_225page { class Cat { public string Name; public string Color; public void Meow() { Console.WriteLine($"{Name}: 야옹"); } } class Program { static void Main(string[] args) { Cat kitty = new Cat(); kitty.Color = "하얀색"; kitty.Name = "키티"; kitty.Meow(); Console.WriteLine($"{kitty.Name}: {kitty.Color}"); Cat nero = new Cat(); nero.Color = "검은색"; ..
오늘도 디카페인 커피를 타 왔다. 화이팅 1. 실습_Calculator using System; namespace Method { class Calculator { public static int Plus (int a, int b) { return a + b; } public static int Minus(int a, int b) { return a - b; } } } namespace _6장_Calculator_188page { class Program { static void Main(string[] args) { int result = Method.Calculator.Plus(3, 4); Console.WriteLine(result); result = Method.Calculator.Minus(5,..
오늘도 어디 해 보실까 1. 실습_ArithmaticOperators using System; namespace _4장_ArithmaticOperators_119page { class Program { static void Main(string[] args) { int a = 111 + 222; Console.WriteLine($"a: {a}"); int b = a - 100; Console.WriteLine($"b: {b}"); int c = b * 10; Console.WriteLine($"c: {c}"); double d = c / 6.3; Console.WriteLine($"d: {d}"); Console.WriteLine($"22/7={22 / 7}({22 % 7})"); } } } 2. 실습_..
오늘도 화이팅 1. 실습_SignedUnsigedConversion using System; namespace _3장_SignedUnsigedConversion_74page { class Program { static void Main(string[] args) { int a = 500; Console.WriteLine(a); uint b = (uint)a; Console.WriteLine(b); int x = -30; Console.WriteLine(x); uint y = (uint)x; // under flow 발생 Console.WriteLine(y); } } } 2. 실습_FloatToIntegeral using System; namespace _3장_FloatToIntegeral_75page {..

오늘부터는 C#도 공부하기로 했다. 교재는 "이것이 C#이다"를 구매했다. 게임잡을 둘러보니 온코테는 C++로 보고 실무는 C#으로 진행되는 경우도 흔하게 볼 수 있었다. 그리고 아무래도 유니티를 쓰려면 C#을 쓸 줄 알아야하니 공부하기로 했다. 이전에도 C#으로 간단한 프로그램을 만든 적이 있었지만 본격적으로 공부하는 건 이번이 처음이다. 1. 실습_Hello World C#의 기초적인 부분은 대강 알고 있기는 하지만, 새 언어를 배울 때마다 Hello World 파일을 만들지 않으면 뭔가 빼먹은 기분이 들어서 패스하지 않고 따라해보았다. using System; using static System.Console; namespace Hello { class Program { static void Mai..