Constructor for an immutable struct
Posted
by Danvil
on Stack Overflow
See other posts from Stack Overflow
or by Danvil
Published on 2010-05-02T15:06:05Z
Indexed on
2010/05/02
15:07 UTC
Read the original article
Hit count: 152
c#
Consider the following simple immutable struct:
struct Stash {
public int X { get; private set; }
public Stash(int _x) {
X = _x;
}
}
This is not working, because the compiler wants me to initialize the "backing field" before I can access the property. How can I solve this?
© Stack Overflow or respective owner