Re: List<> of struct with property. Cannot change value of property. why?
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Mon, 14 May 2007 19:55:44 +0100
Zytan <zytanlithium@xxxxxxxxx> wrote:
I guess this could be shortened to:
list[index].MethodThatChangesStructsFields();
Confirmed. This operates on the COPY, and any changes are lost, and
the compiler does NOT warn about this.
No, and there's no way it could. There's nothing available to the
compiler to let it know that the method changes the contents of the
struct.
(Remember when we warned you about making mutable structs, back in
March? This is just one of the problems. Just say no to mutable
structs, basically :)
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- References:
- List<> of struct with property. Cannot change value of property. why?
- From: Zytan
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Bruce Wood
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Zytan
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Zytan
- List<> of struct with property. Cannot change value of property. why?
- Prev by Date: Re: ?? Basic C# Language Questions ??
- Next by Date: Re: why no struct inheritance?
- Previous by thread: Re: List<> of struct with property. Cannot change value of property. why?
- Next by thread: Re: List<> of struct with property. Cannot change value of property. why?
- Index(es):
Relevant Pages
|
Loading