Syntax Sugar in C#

Many ways to write the same code in your program

--

Syntax Sugar or Syntactic Sugar is a “shortcut” provided for languages to reduce the amount of code that you can write in common situations. The objective of Syntax Sugar is make the code cleaner and easier to read (is not always the case specially for beginner programmers).

Some examples of Syntax Sugar in C#

  • Arithmetic operations:
  • Increment/Decrement by 1:
  • Declare variables:
  • Negation:
  • Conditional operator:

Conclusion:

In the end it doesn’t matter how you write your code as long it is functional, but it is good to know the different ways to do that because when you work in a team it is very probable that the other members use this and you’re gonna understand it.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Rusben Guzman
Rusben Guzman

Written by Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

No responses yet

Write a response