Guest User

Untitled

a guest
Oct 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. public void ScopeAndDefiniteAssigning(object o)
  2. {
  3. if (o is string s && s.Length != 0)
  4. {
  5. Console.WriteLine("o is not empty string");
  6. }
  7.  
  8. // 더 이상 's'를 사용할 수 없습니다. 's'는 현재 스코프에서 이미 선언된 변수이기 때문입니다.
  9. if (o is int n || (o is string s2 && int.TryParse(s2, out n)))
  10. {
  11. Console.WriteLine(n);
  12. }
  13. }
Add Comment
Please, Sign In to add comment