tags:

views:

55

answers:

3

If there is only a set part in a Property, then is there any need to declare a return type? For example:

public string Email
{
   set { email = value; }
}

In the above example is there any need of the word "string" after public?

+3  A: 

Otherwise you wouldn't know the type of value.

Yuriy Faktorovich
Thanks Yuri Fatorovich.
+4  A: 

Yes. The compiler needs to know so that it can check the type when you try to set the property.

Rowland Shaw
Thanks Rowland Shaw.
+1  A: 

The simple answer is: It's not possible to have a property without a type

Think that value is of the type that you specified so it's not that it's not being used.

Claudio Redi
Thanks Claudio Redi.