I am wondering what type the 'value' keyword in a property takes.
so:
public class Test
{
string _numberAsString;
int _number = -1;
public Test() {}
public string NumberAsString
{
get { return _numberAsString; }
set { _numberAsString= value; }
}
public int Number
{
get { return int.Parse(_numberAsString); }
set { _number = value; }
}
}
//elsewhere
Test t = new Test();
t.Number = 5;
Now, this doesn't compile, as I'd expect. The type of 'value' is determined by the return type of the property, is that correct? I couldn't find anything to that effect, perhaps it's too obvious (I haven't read the language specs, presumably there's something in there).
I ask, because I would like to set the property with a type that is then converted into the type of the getter. I suppose this doesn't really make sense.
It seems I will have to achieve this by creating a couple of methods.