C# 7.0 – #2. Numbers code readability

These are some minor but nice improvements regarding numbers code readability:

Now it is possible to write digit separator of number literals:
The digit separator is the “_” character, like in Java language, isn’t it ?

int number = 1_345_782
Console.WriteLine(number); // prints 1345782

This is mostly useful for large numbers.
The separator is ignored by the compiler; it’s just used to improve the numbers readability, and it can be placed anywhere inside the number, but only inside, not at beginning or at the end for instance:

// this not compile
int number = _1_345_782
int number = 1_345_782_

Strange but true, the separator can be multiple, i.e. you can place more than one separator one beside another:

// this is allowed
int strangeNumber = 1_____2______3______4______5;

For decimal number, it cannot be placed right before the separator character:

// this not compile
double numberDouble = 12_.34;

Same for type specifier:

// this not compile
float numbewFloat = 12_f;

Finally it is available the literal for binary constant values (0b):

int binaryNumber = 0b0100_0010;
Console.WriteLine(binaryNumber); // prints 66

447 thoughts on “C# 7.0 – #2. Numbers code readability

  1. Pingback: canadian drug
  2. Pingback: online drug store
  3. Pingback: kertyun.flazio.com
  4. Pingback: canadian pharmacy
  5. Pingback: canadian pharmacy
  6. Pingback: viagra canada
  7. Pingback: online pharmacies
  8. Pingback: kwersv.proweb.cz
  9. Pingback: sdtyli.zombeek.cz
  10. Pingback: canada pharmacy
  11. Pingback: canadian drugs
  12. Pingback: stromectol coupon
  13. Pingback: stromectol rosacea
  14. Pingback: stromectol biam
  15. Pingback: ivermectine
  16. Pingback: canada pharmacies
  17. Pingback: stromectol cream
  18. Pingback: canadian viagra
  19. Pingback: canada rx
  20. Pingback: canadian rx
  21. Pingback: dose of stromectol
  22. Pingback: stromectol drug
  23. Pingback: pharmacy canada
  24. Pingback: what is stromectol
  25. Pingback: canadian pharmacy
  26. Pingback: viagra canada
  27. Pingback: drugs for sale
  28. Pingback: online drug store
  29. Pingback: canadian viagra
  30. Pingback: canadian drugstore
  31. Pingback: drugs for sale
  32. Pingback: canadianpharmacy
  33. Pingback: canada viagra
  34. Pingback: www.dibiz.comgdooc
  35. Pingback: canadian pharmacy
  36. Pingback: canadian pharmacys
  37. Pingback: canada medication
  38. Pingback: northwestpharmacy
  39. Pingback: canadian cialis
  40. Pingback: cialis cheap
  41. Pingback: tamoxifen pancreas
  42. Pingback: furosemide studies
  43. Pingback: vitiligo metformin
  44. Pingback: bactrim brand name
  45. Pingback: gaia ashwagandha
  46. Pingback: abilify and prozac
  47. Pingback: what is augmentin
  48. Pingback: valtrex pregnancy
  49. Pingback: sildenafil canada

Comments are closed.