Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. switch (e.PropertyName)
  2. {
  3. case nameof(SomeProperty):
  4. { break };
  5.  
  6. // opposed to
  7. case "SomeOtherProperty":
  8. { break;}
  9. }
  10.  
  11. public string DoSomething(string input)
  12. {
  13. if(input == null)
  14. {
  15. throw new ArgumentNullException(nameof(input));
  16. }
  17. ...
  18.  
  19. throw new ArgumentException(nameof(T), $"Type {typeof(T)} does not support this method.");
  20.  
  21. //Currently
  22. void Foo(string par) {
  23. if (par == null) throw new ArgumentNullException("par");
  24. }
  25.  
  26. //C# 6 nameof
  27. void Foo(string par) {
  28. if (par == null) throw new ArgumentNullException(nameof(par));
  29. }
  30.  
  31. public void DoStuff(object input)
  32. {
  33. if (input == null)
  34. {
  35. throw new ArgumentNullException(nameof(input));
  36. }
  37. }
  38.  
  39. int myVar = 10;
  40. print("myVar" + " value is " + myVar.toString());
  41.  
  42. print(nameof(myVar) + " value is " + myVar.toString());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement