code_junkie

Is it OK to use assignments in expressions?

Nov 12th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. Class ReportClass
  2. {
  3. public string ReportName {get; set;}
  4. }
  5.  
  6. displayReport(ReportClass.ReportName = cmbReportName.SelectedValue.ToString())
  7.  
  8. ReportClass.ReportName = cmbReportName.SelectedValue.ToString();
  9. displayReport(ReportClass.ReportName);
  10.  
  11. string line;
  12. while ((line = reader.ReadLine()) != null)
  13. {
  14. // Do something with line
  15. }
  16.  
  17. Foo(new Bar { X=1, Y=2 });
  18.  
  19. var a = 0;
  20. var b = 0;
  21.  
  22. // This makes a *and* b equals to 1
  23. a = b = 1;
  24.  
  25. // This line prints 3 and a is now equals to 3
  26. Console.WriteLine(a = 3);
  27.  
  28. // This line prints 7 and a and b is now equals to 7
  29. Console.WriteLine(a = b = 7);
  30.  
  31. displayReport(
  32. ReportClass.ReportName = cmbReportName.SelectedValue.ToString());
  33.  
  34. var reportName = cmbReportName.SelectedValue.ToString();
  35.  
  36. displayReport(ReportClass.ReportName = reportName);
  37.  
  38. int a, b, c;
  39. a = b = c = 0;
  40.  
  41. while ((packetPos = Packet.FindStart(buffer, nextUnconsideredPos)) > -1)
  42.  
  43. packetPosition = Packet.FindStart(buffer, nextUnconsideredPosition);
  44. while (packetPosition > -1)
  45. {
  46. ...
  47. packetPosition = Packet.FindStart(buffer, nextUnconsideredPosition);
  48. }
Add Comment
Please, Sign In to add comment