J
JSheble
Are there any reasons why I shouldn't or couldn't use a structure as a
property in a class? Specifically since structures are value types and
objects are reference types?
I have a Shipping object that has 4 different types of addresses.
Initially, I created 4 instances of an Address object, but seem
inefficient to me since the Address itslef doesn't really have (or need)
and methods... I was thinking a structure would be more efficient, but
thought that the different types (reference v.s. value) might cause a
problem when passing the object around...
I could also use some help in acessibility or scope. I don't want the
user of my object to create an instance of the Address class (structure?)
(as well as a few other objects), but they do need to access pieces of a
created Address.
Hmmm, I'm not sure I explained that well...
I do want the user of the class to be able to do this:
oShipment.ShipTo.Address1 = "blah blah blah"
But I don't want them to be able to do this:
oAddress = new Address();
oAddress.Address1 = "blah blah blah"
What's the best way to accomplish this?
Thanx!
Joe
property in a class? Specifically since structures are value types and
objects are reference types?
I have a Shipping object that has 4 different types of addresses.
Initially, I created 4 instances of an Address object, but seem
inefficient to me since the Address itslef doesn't really have (or need)
and methods... I was thinking a structure would be more efficient, but
thought that the different types (reference v.s. value) might cause a
problem when passing the object around...
I could also use some help in acessibility or scope. I don't want the
user of my object to create an instance of the Address class (structure?)
(as well as a few other objects), but they do need to access pieces of a
created Address.
Hmmm, I'm not sure I explained that well...
I do want the user of the class to be able to do this:
oShipment.ShipTo.Address1 = "blah blah blah"
But I don't want them to be able to do this:
oAddress = new Address();
oAddress.Address1 = "blah blah blah"
What's the best way to accomplish this?
Thanx!
Joe