인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

jinheehan's profile image
jinheehan

asked

[MMORPG Game Development Series with C# and Unity] Part 1: Introduction to Basic C# Programming

Class type conversion

Mage mage = (player as Mage); 에서는 Console.WriteLine 사용할 수 없나요.

Resolved

Written on

·

219

0

시도

콘솔창에 Console.WriteLine("당신은 메이지가 아닙니다");

해당 텍스트를 입력하였고

메인에서    EnterGame(knight);을 입력하고 메시지를 받으려고 시도해봤습니다.

결과물

breakpoint를 헤제시키고 콘솔창에 cw 입력한건 보이질 않습니다.

이 as 나 is라는 것을 사용할 땐 cw + tab,tab을 사용할 수가 없는 것인가요? 아니면 다른 빠뜨린게 뭔가 있는걸까요?

C#

Answer 1

1

rookiss님의 프로필 이미지
rookiss
Instructor

로직이 거꾸로 됐네요.
mage == null일 때가 [마법사가 아닌] 것이고,
mage != null이면 [마법사가 맞음]이 정확한 상태이니,
사실 코드는 제대로 실행되고 있는겁니다 (knight을 입력하셨으니)

jinheehan's profile image
jinheehan

asked

Ask a question