one line struct initialization

  • Thread starter Thread starter Zytan
  • Start date Start date
Even for structs? But sometimes a struct is just something simple,
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
 
Zytan said:
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.

There's nothing wrong with readonly - but it doesn't mean that it
wouldn't be better to provide properties than public variables.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top