Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
GeneralRe: Windows service & Timers Pin
koleraba12-Feb-10 11:04
koleraba12-Feb-10 11:04 
QuestionRe: Windows service & Timers Pin
koleraba12-Feb-10 12:39
koleraba12-Feb-10 12:39 
AnswerRe: Windows service & Timers Pin
22491714-Feb-10 17:33
22491714-Feb-10 17:33 
GeneralRe: Windows service & Timers Pin
koleraba14-Feb-10 23:50
koleraba14-Feb-10 23:50 
QuestionA few pointers toward design Pin
Saksida Bojan12-Feb-10 9:00
Saksida Bojan12-Feb-10 9:00 
AnswerRe: A few pointers toward design Pin
Dan Mos12-Feb-10 9:13
Dan Mos12-Feb-10 9:13 
GeneralRe: A few pointers toward design Pin
Rozis12-Feb-10 11:45
Rozis12-Feb-10 11:45 
AnswerRe: A few pointers toward design Pin
DaveyM6912-Feb-10 13:18
professionalDaveyM6912-Feb-10 13:18 
Saksida Bojan wrote:
should chose a class or a struct


This is a long running debate and the general consensus seems to be...

Structs should be used for things that hold a specific value that cannot be changed. If it needs to be changed then a new instance is required (immutable). For example, Size. If either the width or height changes then a new instance is assigned to the variable as it's now a different size!

An object such as a Form would always be a class as changing a property would not create a new form.

A class that holds other class/struct instances is normally the best way to go and far easier to deal with.

There are other issues such as recommended size of structs etc. If you do seriously consider using a struct I would do some serious research first and learn about the stack/heap etc...


Saksida Bojan wrote:
Does a class and struct compare by reference


Do you mean pass by reference? Structs(being values) are passed by value and classes are passed by reference, although you can use references with structs by using ref / out.
Dave

Tip: Passing values between objects using events (C#)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)

GeneralRe: A few pointers toward design [modified] Pin
Saksida Bojan12-Feb-10 18:54
Saksida Bojan12-Feb-10 18:54 
GeneralRe: A few pointers toward design Pin
DaveyM6912-Feb-10 23:42
professionalDaveyM6912-Feb-10 23:42 
GeneralRe: A few pointers toward design Pin
Saksida Bojan13-Feb-10 0:10
Saksida Bojan13-Feb-10 0:10 
GeneralRe: A few pointers toward design Pin
DaveyM6912-Feb-10 23:55
professionalDaveyM6912-Feb-10 23:55 
Questionbaseclass and a interface. Pin
Jarno Burger12-Feb-10 8:42
Jarno Burger12-Feb-10 8:42 
AnswerRe: baseclass and a interface. Pin
Saksida Bojan12-Feb-10 10:16
Saksida Bojan12-Feb-10 10:16 
AnswerRe: baseclass and a interface. Pin
rhuiden12-Feb-10 10:24
rhuiden12-Feb-10 10:24 
GeneralRe: baseclass and a interface. Pin
Jarno Burger14-Feb-10 13:33
Jarno Burger14-Feb-10 13:33 
Questioncodes Pin
ajay 201012-Feb-10 7:27
ajay 201012-Feb-10 7:27 
AnswerRe: codes Pin
Wes Aday12-Feb-10 7:46
professionalWes Aday12-Feb-10 7:46 
GeneralRe: codes Pin
ajay 201012-Feb-10 16:41
ajay 201012-Feb-10 16:41 
GeneralRe: codes Pin
Wes Aday12-Feb-10 17:11
professionalWes Aday12-Feb-10 17:11 
GeneralRe: codes Pin
ajay 201012-Feb-10 18:04
ajay 201012-Feb-10 18:04 
GeneralRe: codes Pin
ajay 201012-Feb-10 18:51
ajay 201012-Feb-10 18:51 
AnswerRe: codes Pin
hammerstein0512-Feb-10 8:00
hammerstein0512-Feb-10 8:00 
GeneralRe: codes Pin
ajay 201012-Feb-10 16:43
ajay 201012-Feb-10 16:43 
GeneralRe: codes Pin
hammerstein0512-Feb-10 18:35
hammerstein0512-Feb-10 18:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.