알 수 없는 사용자 2024. 1. 24. 18:46

파이썬에서는 하단과 같은 에러 처리가 가능하다.

python 은 동적 타입 언어이므로 a = qwesa 같은 에러가 컴파일 에러가 아닌 런타임 에러기 때문에 try except 나 try catch 같은 예외 처리가 가능하다.

하지만 C#은 정적 타입 언어이므로 a = qwesa 같은 에러는 컴파일단계에서 에러가 나므로 try except 나 try catch 로 예외처리가 불가능 하다.

O

try:
    a = qwesa
except Exception as e:
    print(1111111111111111)

X

try
{
    var a = "qwesa"; // 'qwesa'를 문자열 리터럴로 정의합니다.
}
catch (Exception e)
{
    Console.WriteLine(1111111111111111L);
}

 

python 에서 "raise TypeError("에러명 기입")"

C# 에서는 "throw new ArgumentException("에러명 기입");"


https://learn.microsoft.com/ko-kr/dotnet/csharp/fundamentals/coding-style/identifier-names