Wednesday, January 03, 2007 3:50 AM
bart
C# Quiz - Field initialization
Saw a good question on the discussion lists yesterday:
What is the difference (practically) in assigning a variable value in the variable declaration line and in the constructor?
So, here's the quiz question: What's the difference between the following two code fragments?
Fragment 1:
class Bar
{
private int i = 123;
public Bar()
{
}
}
Fragment 2:
class Bar
{
private int i;
public Bar()
{
i = 123;
}
}
Tip: the difference is rather subtle.
I'll post another code fragment for this quiz tomorrow "on the road to the solution".
Del.icio.us |
Digg It |
Technorati |
Blinklist |
Furl |
reddit |
DotNetKicks
Filed under: C# 2.0