Re: one line struct initialization

Tech-Archive recommends: Fix windows errors by optimizing your registry



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

.



Relevant Pages

  • Re: .NET2.0: Microsoft, you got something very wrong in data validation..
    ... The constraint check is a type of validation - and it already ... columns are in error (but i'd have expected a ConstraintException to ... its underlying data chain contains "oldvalue" at every other step. ... If this is a design no-no then do let me know ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: How to change bound continuous form with required fields
    ... - added an extra field to the underlying table called RecordComplete which ... - put put some validation on the form unload event which cancels the event ... if the validation fails (i.e. check all underlying fields in the ... I've got a continuous form bound to a table with required fields. ...
    (microsoft.public.access.forms)
  • Re: Pass a lot of parameters?
    ... However, if I've defined a class with 40 columns and validations code, how ... The difference between this and a struct ... > and ensuring bounds, ... > much data to update, just doing this field validation can be a handful, so ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do you print out details of the file structure of a database?
    ... Tools> Analyze> Documenter. ... Data type ... Validation check ...
    (microsoft.public.access.gettingstarted)