Re: one line struct initialization
- From: "Zytan" <zytanlithium@xxxxxxxxx>
- Date: 8 Mar 2007 11:48:59 -0800
Even for structs? But sometimes a struct is just something simple,
like holding x and y for the concept of a point.
That doesn't mean it's not worth encapsulating them in properties.
Non-private fields are highly discouraged. You get much more control
and power with properties. You can add in validation etc later, or even
potentially change the underlying type/implementation without callers
caring.
Yes, that's true. I will do this.
Actually, the readonly modifier could be useful. It doesn't allow
validation or letting the underlying implementation change, but in my
case, there is nothing to validate, it's just a storage place for
strings/ints, to *later* to analyzed, such as for network traffic. I
don't want to validate it on storage, I'll do that later. This struct
is storing to make it easier to analyze later, rather than attempting
to analyze too much info at once. And, the underlying structure will
never change (if it ever does, a lot more than this struct would have
to change).
I assume it is ok for me to use readonly. Some people must use it
properly somewhere, or it wouldn't be included in the language.
Zytan
.
- Follow-Ups:
- Re: one line struct initialization
- From: Jon Skeet [C# MVP]
- Re: one line struct initialization
- References:
- one line struct initialization
- From: Zytan
- Re: one line struct initialization
- From: Mattias Sjögren
- Re: one line struct initialization
- From: Zytan
- Re: one line struct initialization
- From: Jon Skeet [C# MVP]
- Re: one line struct initialization
- From: Zytan
- Re: one line struct initialization
- From: Jon Skeet [C# MVP]
- Re: one line struct initialization
- From: Zytan
- Re: one line struct initialization
- From: Jon Skeet [C# MVP]
- Re: one line struct initialization
- From: Zytan
- one line struct initialization
- Prev by Date: Re: Inexplicable slowdowns
- Next by Date: Non .Net C++ xmlrpc to C#
- Previous by thread: Re: one line struct initialization
- Next by thread: Re: one line struct initialization
- Index(es):
Relevant Pages
|