강의

멘토링

커뮤니티

Inflearn Community Q&A

gjtnwls73863156's profile image
gjtnwls73863156

asked

WinForms C#.Net Framework 0.5 to 3 years of experience (Part 2)

5. Network - TCP communication (client, practical)

OnConnected != null

Written on

·

252

0

OnConnected != null 에서

OnConnected가 null 이 아닌 상태를 알 수 있는건

실행창에서 textbox에 ip, port를 입력했기때문...

이렇게 생각하면 맞을까요 ?

 

 

network.NETC#

Answer 1

0

vmproductor0202님의 프로필 이미지
vmproductor0202
Instructor

안녕하세요.

개발자 park입니다.

자세한 설명은 https://www.inflearn.com/course/%EB%8B%B7%EB%84%B7-%EC%9C%88%ED%8F%BC-2/unit/77904?tab=curriculum

하단의 설명을 참조해주세요.

[답변]

실무에서도 event에대해서 null체크를 합니다.

가령

var handler = OnConnected;

if (handler != null)

{

handler(socket);

}

위와 같이하는 이유는 EVENT에대한 구독자가 없을 시 null이기 때문입니다.

감사합니다.

gjtnwls73863156's profile image
gjtnwls73863156

asked

Ask a question