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

Assignment

Besides declaration of local variables, there’s also the need to initialize them before they can be used. C# is very strict about not permitting the use of uninitialized variables because that’s a very common source of errors found in other languages. For this very reason, the following fragment won’t compile:

int x;// Error: Use of unassigned local variable 'x'.Console.WriteLine(x);

To ensure variables are properly assigned before they get used, C# has several rules on definite assignment, based on static program flow analysis. I won’t go into detail about those, but I’ll sometimes mention some of the rules in passing.

Assignment is the act of substituting the contents of the storage cell associated with ...

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