0
votes
1answer
424 views

When to use (Or not) C# myVariable { set; get; }

I have been trying to wrap my head around the finer points of this today. Essentially I have fallen in love with this format for booleans: Class { public static bool myBool {set; get;} private ...
6
votes
3answers
7k views

What is meant by Scope of a variable?

I think of the scope of a variable as - "The scope of a particular variable is the range within a program's source code in which that variable is recognized by the compiler". That statement is ...
10
votes
9answers
2k views

Why do variables need a type?

So we write: Customer c = new Customer(); Why is the design not such that we write: c = new Customer(); c.CreditLimit = 1000; The compiler can work out c points to a Customer and allow ...
1
vote
6answers
3k views

Why declare variables close to where they are used?

I have heard people say that variables should be declared as close to their usage as possible. I don't understand this. For example, this policy would suggest I should do this: foreach (var item in ...
5
votes
7answers
3k views

How to abbreviate variable names

I always struggle in abbreviating variable names. Is there any standard for abbreviating variable names?
20
votes
6answers
9k views

C#: Explicitly defining variable data types vs. using the keyword 'var'?

In C#, am I encouraged to use the all-purpose var keyword for every variable declaration? If yes, do I have to mention those special characters for literal values within the variable declaration like ...