using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp11
{
class Program
{
static void Dosomething(int n)
{
if (n < 10) Console.WriteLine($"{n}");
else throw new Exception("n이 10보다 큽니다"); //강제로 예외던지기(throw)
}
static void Main(string[] args)
{
try {
Dosomething(1);
Dosomething(5);
Dosomething(10);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
'코딩연습 > C#' 카테고리의 다른 글
[C#]LINQ (0) | 2020.06.12 |
---|---|
[C#]대리자의 이벤트 (0) | 2020.06.12 |
[C#]대리자 체인 (0) | 2020.06.12 |
[C#]대리자(delegate) (0) | 2020.06.12 |
[C#]오라클 연동 (0) | 2020.06.11 |