https://www.youtube.com/watch?v=YNl63E5gzGU&list=PLO56HZSjrPTB4NxAsEP8HRk6YKBDLbp7m&index=42
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Red");
Console.ResetColor();
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
switch (ConsoleColor)
{
case ConsoleColor.Black:
break;
case ConsoleColor.DarkBlue:
break;
case ConsoleColor.DarkGreen:
break;
case ConsoleColor.DarkCyan:
break;
case ConsoleColor.DarkRed:
break;
case ConsoleColor.DarkMagenta:
break;
case ConsoleColor.DarkYellow:
break;
case ConsoleColor.Gray:
break;
case ConsoleColor.DarkGray:
break;
case ConsoleColor.Blue:
break;
case ConsoleColor.Green:
break;
case ConsoleColor.Cyan:
break;
case ConsoleColor.Red:
break;
case ConsoleColor.Magenta:
break;
case ConsoleColor.Yellow:
break;
case ConsoleColor.White:
break;
default:
}
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
enum Animal { Mouse, Cow, Tiger };
static void Main(string[] args)
{
Animal animal = Animal.Tiger;
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
enum Animal { Mouse, Cow, Tiger };
static void Main(string[] args)
{
Animal animal = Animal.Tiger;
// 변수 안의 내용
WriteLine(animal);
// 변수 값의 인덱스
WriteLine((int)animal);
// 문자열로 값 가져오기
WriteLine(nameof(Animal.Tiger));
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
enum Animal { Mouse, Cow = 5, Tiger };
static void Main(string[] args)
{
Animal animal = Animal.Tiger;
// 변수 값의 인덱스
WriteLine((int)animal);
}
}
}