On Thu, 05 Jul 2007 06:25:35 -0700, Paul Richardson <pa**@pnr-group.co.uk
wrote:
[...]
With this i get referancing errors when i do the following:
UKAddress address = new UKAddress();
isPostCodeValid = address.PostCode.SetPostCode("NE1 4DU");
I'm i surpose to using ref or out ??
I don't see any practical difference between the two, other than of course
the nice encapsulation that using the property offers. If you are getting
an error, please post the _exact_ error message you are getting. From the
code you posted, I don't see anything that should generate an error, and
it seems like a fine way to do what you seem to be asking to do. Which
suggests that the code you posted is not actually the same as the code
you're trying to compile. :)
I also agree with Jon on his other two points: you may want to consider
making the UKPostCode class immutable, and for better assistance here you
should post a concise-but-complete sample of code that reliably reproduces
your problem.
With respect to making the class immutable, that would mean that you could
only construct a new UKPostCode instance, and the SetPostCode() method
would go away. You'd use the property for the UKAddress class only to get
or set the current UKPostCode instance, rather than getting it for the
purpose of modifying the instance.
Pete