45 lines
1.1 KiB
Plaintext
45 lines
1.1 KiB
Plaintext
![]() |
=== On 2014-12-16T20:40:12Z Ann Campbell Wrote:
|
||
|
\[~dinesh.bolkensteyn] what about a property which has logic in one of the methods but not the other?
|
||
|
|
||
|
=== On 2014-12-17T06:38:06Z Dinesh Bolkensteyn Wrote:
|
||
|
I've tested that yesterday [~ann.campbell.2], it's not possible: There is no way to explicitly access the implicit backing field, so there is no way to add any logic to an auto-property.
|
||
|
|
||
|
=== On 2014-12-17T13:01:10Z Ann Campbell Wrote:
|
||
|
\[~dinesh.bolkensteyn] I'm not sure I was clear. I'm talking about something like this:
|
||
|
|
||
|
----
|
||
|
private string _make;
|
||
|
public string Make // Noncompliant
|
||
|
{
|
||
|
get { return _make; }
|
||
|
set
|
||
|
{
|
||
|
// do stuff to value...
|
||
|
_make = value;
|
||
|
}
|
||
|
}
|
||
|
----
|
||
|
|
||
|
=== On 2014-12-17T13:05:37Z Dinesh Bolkensteyn Wrote:
|
||
|
So you actually mean:
|
||
|
|
||
|
|
||
|
----
|
||
|
private string _make;
|
||
|
public string Make
|
||
|
{
|
||
|
get { return _make; }
|
||
|
set
|
||
|
{
|
||
|
if (value == null)
|
||
|
{
|
||
|
throw new SomeException();
|
||
|
}
|
||
|
_make = value;
|
||
|
}
|
||
|
}
|
||
|
----
|
||
|
|
||
|
That is perfectly valid and compliant. There is nothing that can be improved there.
|
||
|
|