Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void ScopeAndDefiniteAssigning(object o)
- {
- if (o is string s && s.Length != 0)
- {
- Console.WriteLine("o is not empty string");
- }
- // 더 이상 's'를 사용할 수 없습니다. 's'는 현재 스코프에서 이미 선언된 변수이기 때문입니다.
- if (o is int n || (o is string s2 && int.TryParse(s2, out n)))
- {
- Console.WriteLine(n);
- }
- }
Add Comment
Please, Sign In to add comment