Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
Questionhorizontal scroll bar move event... Pin
spalanivel28-Jul-09 21:21
spalanivel28-Jul-09 21:21 
AnswerRe: horizontal scroll bar move event... Pin
stancrm28-Jul-09 21:43
stancrm28-Jul-09 21:43 
GeneralRe: horizontal scroll bar move event... Pin
spalanivel28-Jul-09 22:00
spalanivel28-Jul-09 22:00 
GeneralRe: horizontal scroll bar move event... Pin
spalanivel29-Jul-09 0:53
spalanivel29-Jul-09 0:53 
AnswerRe: horizontal scroll bar move event... Pin
Alan N29-Jul-09 2:03
Alan N29-Jul-09 2:03 
QuestionOOP approach, static method Pin
Raybarg28-Jul-09 20:46
professionalRaybarg28-Jul-09 20:46 
AnswerRe: OOP approach, static method Pin
Christian Graus28-Jul-09 21:00
protectorChristian Graus28-Jul-09 21:00 
AnswerRe: OOP approach, static method Pin
DaveyM6928-Jul-09 22:41
professionalDaveyM6928-Jul-09 22:41 
Generally, static methods shouldn't be creating instances of the class they 'live' in. If a static method requires access to instance fields/properties/methods then it should probably not be static as it's working on instance data. A general exception is in situations where an instance wouldn't previously exist but will do at the end of the method. A good example is int.Parse. This (in it's simplest form) takes a string as a parameter and it creates an int from it. It would make no sense to have this as an instance method in the int struct as until the string is parsed, there is no int.

In your situation, your Print method is obviously related to a TheDocument instance so I would remove the static and the parameter. If I wished it to be static for convenience, I would rename it to PrintTheDocument, so it's obvious the method is only for printing TheDocument instances, and take an instance of the class as a parameter,
public static void PrintTheDocument(TheDocument theDocument)
{       
    // ...     
}
though there's no advantage to be had as you could simply call
theDocument.Print();
instead of
TheDocument.PrintTheDocument(theDocument);
.

There is another common occaision when a static will create an instance, and this can be very useful. This is when creating a 'singleton[^]'.

Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus)

GeneralRe: OOP approach, static method Pin
Raybarg28-Jul-09 23:04
professionalRaybarg28-Jul-09 23:04 
GeneralRe: OOP approach, static method Pin
DaveyM6928-Jul-09 23:39
professionalDaveyM6928-Jul-09 23:39 
AnswerRe: OOP approach, static method Pin
PIEBALDconsult29-Jul-09 4:58
mvePIEBALDconsult29-Jul-09 4:58 
QuestionAttach User Entered Data with word Document while saving Pin
mandar77728-Jul-09 20:41
mandar77728-Jul-09 20:41 
QuestionTreeView NodeMouseHover Event Pin
vhassan28-Jul-09 20:15
vhassan28-Jul-09 20:15 
QuestionDisplay Image from Path Pin
nudma28-Jul-09 19:47
nudma28-Jul-09 19:47 
AnswerRe: Display Image from Path Pin
Christian Graus28-Jul-09 20:10
protectorChristian Graus28-Jul-09 20:10 
AnswerRe: Display Image from Path Pin
Blikkies28-Jul-09 20:14
professionalBlikkies28-Jul-09 20:14 
GeneralRe: Display Image from Path Pin
nudma28-Jul-09 21:15
nudma28-Jul-09 21:15 
GeneralRe: Display Image from Path Pin
Blue_Boy29-Jul-09 0:45
Blue_Boy29-Jul-09 0:45 
GeneralRe: Display Image from Path Pin
Blikkies29-Jul-09 1:32
professionalBlikkies29-Jul-09 1:32 
GeneralRe: Display Image from Path Pin
nudma29-Jul-09 4:08
nudma29-Jul-09 4:08 
GeneralRe: Display Image from Path Pin
Blue_Boy29-Jul-09 7:38
Blue_Boy29-Jul-09 7:38 
GeneralRe: Display Image from Path Pin
Blikkies29-Jul-09 8:26
professionalBlikkies29-Jul-09 8:26 
AnswerRe: Display Image from Path Pin
Blue_Boy28-Jul-09 20:23
Blue_Boy28-Jul-09 20:23 
AnswerRe: Display Image from Path Pin
Christian Graus28-Jul-09 21:01
protectorChristian Graus28-Jul-09 21:01 
QuestionApp with Crystal Reports Pin
CodingYoshi28-Jul-09 11:00
CodingYoshi28-Jul-09 11:00 

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.