Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whitespace in C#

Tags:

c#

whitespace

I'm a bit of a sucker for tidy code, so I like to have everything indented and flowing, if you know what I mean.

private void myFunc()
{
    while(true)
    {
        //do this
    }
}

etc. Now, I know that in a text file, the tab character or four spaces or whatever is actually stored in there, ready for the next time I open it.

If I go to compile this though, am I going to see any benefit in output filesize / compilation performance by not having tidy formatting and indentation, or does the compiler just ignore everything that isn't important?

like image 532
dotalchemy Avatar asked Apr 05 '11 02:04

dotalchemy


People also ask

What is whitespace in C language?

Whitespace is a term that refers to characters that are used for formatting purposes. In C++, this refers primarily to spaces, tabs, and (sometimes) newlines. The C++ compiler generally ignores whitespace, with a few minor exceptions. For example, all the 4 lines below mean the same thing −

Is whitespace a function in c?

C isspace()The isspace() function checks whether a character is a white-space character or not. If an argument (character) passed to the isspace() function is a white-space character, it returns non-zero integer. If not, it returns 0.

What whitespace means?

Definition of white space : the areas of a page without print or pictures.

What is whitespace syntax?

Whitespace is a programming language that only uses spaces, linefeeds, and tabs – the interpreter ignores all other characters. Each command in the Whitespace language consists of a series of tokens. Stack-based languages work using a global stack.


1 Answers

One of the compilation steps is known as tokenization. This step removes all of the whitespace and comments from your code. As long as your code parses correctly, there's no difference between well formatted or poorly formatted code in terms of runtime speed.

like image 112
Gavin Anderegg Avatar answered Sep 28 '22 08:09

Gavin Anderegg