Exercise – Use whitespace to make your code easier to read

Print and web designers understand that putting too much information in a small space overwhelms the viewer. So, they strategically use whitespace, or negative space, to break up information to maximize the viewer’s ability to consume the primary message of their work.

Developers can use a similar strategy when writing code in an editor. By using white space to convey meaning, developers can increase the clarity of their code’s intent.

What is whitespace?

The term “whitespace” refers to individual spaces produced by the space bar, tabs produced by the tab key, and new lines produced by the enter key.

The C# compiler ignores whitespace. To understand how whitespace is ignored, and how to maximize clarity using white space, work through the following exercise.

Add code to illustrate how whitespace is ignored by the C# compiler

  1. Ensure that you have an empty Program.cs file open in Visual Studio Code.If necessary, open Visual Studio Code, and then complete the following steps to prepare a Program.cs file in the Editor:
    1. On the File menu, select Open Folder.
    2. Use the Open Folder dialog to navigate to, and then open, the CsharpProjects folder.
    3. In the Visual Studio Code EXPLORER panel, select Program.cs.
    4. On the Visual Studio Code Selection menu, select Select All, and then press the Delete key.

iso iec 20000 certification training courses malaysia

Leave a Reply

Your email address will not be published. Required fields are marked *