Possible Duplicate:
Why are C# 3.0 object initializer constructor parentheses optional?
Hi all
I have a class Question
which has a property Text
public class Question
{
public string Text { get; set; }
}
Now I want to create an object of this type by giving value to property.
I can do that in this two ways:
Question q = new Question { Text = "Some question" };
and
Question q = new Question() { Text = "Some question" };
Is there any difference between this two cases and if they are the same, why we need both?
Thanks.