C# 7.0 – #6. Usage expanded for statement “throw”

Until C# 6.0 the “throw” keyword must be used only as a standalone statement, that is it cannot be part of an expression. C# 7.0 overcomes this limitation, and then allows this keyword to be placed everywhere, e.g. in the middle of a ternary operator:

string  a = null;
try
{
    // this row doesn't compile in C# 6.0 because of throw statement
    a = a !=  null ? a = " some value" : throw new NullReferenceException("a");
}
catch (Exception ex)
{
    a = "some other value";
    Console.WriteLine("New throw feature: " + a);  // prints "some other value"
}

82 thoughts on “C# 7.0 – #6. Usage expanded for statement “throw”

  1. Pingback: canadianpharmacy
  2. Pingback: canadadrugs
  3. Pingback: drugs for sale
  4. Pingback: canada rx
  5. Pingback: canadian rx
  6. Pingback: fwervs.gumroad.com
  7. Pingback: buy cialis delhi
  8. Pingback: mazhor4sezon
  9. Pingback: filmfilmfilmes
  10. Pingback: canadian cialis
  11. Pingback: gRh9UPV
  12. Pingback: cialis from canada
  13. Pingback: canadianpharmacy
  14. Pingback: online pharmacy
  15. Pingback: 9-05-2022
  16. Pingback: kinoteatrzarya.ru
  17. Pingback: canada drug
  18. Pingback: TopGun2022
  19. Pingback: Xvideos
  20. Pingback: XVIDEOSCOM Videos
  21. Pingback: ivanesva
  22. Pingback: madridbet
  23. Pingback: meritroyalbet
  24. Pingback: meritroyalbet
  25. Pingback: eurocasino
  26. Pingback: dkyubn.bizwebs.com

Comments are closed.