O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Declaration

A first aspect of local variables is their declaration and the scope in which they are available. Declaring a local variable happens in C style, with the type preceding the name:

int a;long b;string c;

Using a comma separator, you can declare different variables of the same type on the same line:

int x, y, z;

Note: Naming Style

Although nothing in the language cares about or mandates the naming pattern used for local variables, here are some useful recommendations to ensure code readability. The short answer is camel casing, where the first letter of a variable’s name is lowercase and subsequent starting letters of concatenated words are uppercase. For example, firstName and htmlDocument are both valid camel-case identifiers.

Camel ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required