Re: List<> of struct with property. Cannot change value of property. why?



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
.



Relevant Pages

  • Re: Dynamically load a dll and us it (in a rexx dll)
    ... The available API functions are dependent on the ODBC version ... The default is usually compiler dependent. ... Depending on the data types used in the structs you ... leave .dll out, it just mentioned path. ...
    (comp.os.os2.programmer.misc)
  • Re: Byte aligned structs
    ... 'data packet' via the serial port. ... structs - i get framing errors for alignment when i apply structs on ... How can i get the compiler to byte align rather than word align. ... routines or macros to insert the shorts and integers for writing and to ...
    (comp.sys.acorn.programmer)
  • Re: About casts (and pointers)
    ... > I believe that whether or not the compiler can deduce that no function ... > The C standard makes guarantees about program execution, ... > about the representations of compatible types (of structs) in ... The C Standard gives a guarantee that under certain circumstances ...
    (comp.lang.c)
  • Re: C/C++ memory-order compiled definitions?
    ... kind of precompiled database:-} Note that DATABASE is just a large ... series of initailized structs with nothing obviuosly tying them ... [Is there any hope of getting a Microsoft compiler person to ... void set1start ...
    (microsoft.public.vc.language)
  • RFC: new IL: C (sort of...).
    ... my existing lower-end codegen is just not very flexible. ... a C compiler (which in turn, produces output I can run through my existing ... I may deprecate support for "inline" struct/union declarations (all structs ...
    (comp.lang.misc)

Loading