Yes, I use them to give a strong type to things like int. For
example, if I have an application with Jobs, Locations and Items, they
will all have an ID that will most likely be an int. I don't want to
accidentally pass a Location ID into a function expecting a Job ID so
each has a struct similar to this:
public struct JobID
{
public int Value;
public JobID(int Value)
{
this.Value = Value;
}
}
The other advantage is if you later decide to use something other than
an int, eg a Guid, you only have to make a change in a couple of
places.
David
"If we can hit that bullseye, the rest of the dominoes
will fall like a house of cards... checkmate!"
-Zapp Brannigan, Futurama
On 17 August 2012 12:35, Williams, Thomas <[email protected]> wrote:
> Hi Arjang, my experience sounds close to yours: DB to WinForms/ASP.NET
> business apps, and no need for structs.
>
>
>
> Thomas
>
>
>
>
>
> From: [email protected] [mailto:[email protected]]
> On Behalf Of Arjang Assadi
> Sent: Friday, 17 August 2012 10:53 AM
> To: ozDotNet
> Subject: Anyone using structs in C# Business Applications?
>
>
>
> Hello
>
>
>
> I have found myself not needing to use structs for any reason in the vanilla
> business apps ( DB to front end WindosForms,WPF,ASP.net etc) for past 7
> years or so.
>
> All BO's are classes, and I can't think of anything more fine grind than
> that.
>
>
>
> Unless I have been missing something, my question is to Business App
> writers, do you use structs any where for any reasons?
>
>
>
> In all the usuall VS demos I have not seen structs being used ( graphics
> demos do not count!)
>
>
>
> Regards
>
>
>
> Arjang
>
>
>
>
> Peninsula Health - Metropolitan Health Service of the Year 2007 & 2009