code_junkie

C# (.NET) Design Flaws

Nov 13th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. public class A
  2. {
  3. public A(string text)
  4. {
  5.  
  6. }
  7. }
  8.  
  9.  
  10. public class Gen<T> where T : new(string text)
  11. {
  12.  
  13. }
  14.  
  15. int? i = myRec.Field;
  16. myRec.Field = null;
  17.  
  18. int? i = (int?)myRec.IsFieldNull() ? (int?)null : myRec.Field;
  19. myRec.SetFieldNull();
  20.  
  21. Dim a = Function(x) x * (x - 1)
  22.  
  23. var a = x => x * (x - 1);
  24.  
  25. Func<int, int> a = x => x * (x - 1);
  26.  
  27. switch (a) {
  28. 1 : do_something;
  29. 2 : do_something_else;
  30. 3,4 : do_something_different;
  31. else : do_something_weird;
  32. }
  33.  
  34. public class MyMixin<T> : T
  35. {
  36. // etc...
  37. }
  38.  
  39. var newMixin = new MyMixin<string>();
  40.  
  41. private string password;
  42.  
  43. public string Password
  44. {
  45. // Called when being set by a deserializer or a persistence
  46. // framework
  47. deserialize
  48. {
  49. // I could put some backward-compat hacks in here. Like
  50. // weak passwords are grandfathered in without blowing up
  51. this.password = value;
  52. }
  53. get
  54. {
  55. if (Thread.CurrentPrincipal.IsInRole("Administrator"))
  56. {
  57. return this.password;
  58. }
  59. else
  60. {
  61. throw new PermissionException();
  62. }
  63. }
  64. set
  65. {
  66. if (MeetsPasswordRequirements(value))
  67. {
  68. throw new BlahException();
  69. }
  70. this.password = value;
  71. }
  72. serialize
  73. {
  74. return this.password;
  75. }
  76. }
  77.  
  78. enum Colors { white, blue, green, red, black, yellow }
  79.  
  80. enum SpecialColors { Colors.blue, Colors.red, Colors.Yellow }
Add Comment
Please, Sign In to add comment