C# 7.0 – #1. New out parameter usage

In C# 7.0 using an out variable is simpler than in older version of the language.
In a nutshell an out variable doesn’t need to be declared anymore before its usage, but can be inline declared just before use it, as shown here:


var n = "2";
//pre-declaration for out parameter variable isn't required anymore
//int p;
//inline declaration for out parameter variable.
int.TryParse(n, out int p);
Console.WriteLine(p);

Furthermore, it’s possible to use the var keyword to inline declare the variable, and not the specific type only, as you would do with C# 6.0 with not initialised pre-declared variables.


var n = "2";
int.TryParse(n, out var p2);
Console.WriteLine(p2);

The inline declared out variables are in scope with the code block that contain them, then they can be used after the declaration inside that block.

If you don’t care about some out function parameter you can complitely ignore them by using wildcards (the “_” symbol).


var n = "2";
int.TryParse(n, out int _);

184 thoughts on “C# 7.0 – #1. New out parameter usage

  1. Pingback: online drug store
  2. Pingback: viagra canada
  3. Pingback: buy cialis no rx
  4. Pingback: mazhor4sezon
  5. Pingback: canadian rx
  6. Pingback: canada drug
  7. Pingback: drugstore online
  8. Pingback: online drug store
  9. Pingback: kertyun.flazio.com
  10. Pingback: buy viagra 25mg
  11. Pingback: cialis from canada
  12. Pingback: Northwest Pharmacy
  13. Pingback: aonubs.website2.me
  14. Pingback: buy viagra 25mg
  15. Pingback: do-posle-psihologa
  16. Pingback: canadian rx
  17. Pingback: cialis from canada
  18. Pingback: Shkala tonov
  19. Pingback: sdtyli.zombeek.cz
  20. Pingback: 3NOZC44
  21. Pingback: 01211
  22. Pingback: canada rx
  23. Pingback: JXNhGmmt
  24. Pingback: Psychologists
  25. Pingback: netstate.ru
  26. Pingback: buy viagra now
  27. Pingback: pharmacy
  28. Pingback: psy
  29. Pingback: bit.ly
  30. Pingback: cleantalkorg2.ru
  31. Pingback: Ukraine-Russia
  32. Pingback: psikholog
  33. Pingback: site
  34. Pingback: UKRAINE
  35. Pingback: film.8filmov.ru
  36. Pingback: filmgoda.ru
  37. Pingback: confeitofilm
  38. Pingback: Dom drakona
  39. Pingback: buy viagra cheap
  40. Pingback: buy viagra usa
  41. Pingback: canada medication
  42. Pingback: stromectol pills
  43. Pingback: link
  44. Pingback: stromectol uk
  45. Pingback: video-2
  46. Pingback: psy-news.ru
  47. Pingback: stromectol mites
  48. Pingback: stromectol france
  49. Pingback: canada drugs

Comments are closed.