Click here to Skip to main content
15,920,383 members
Home / Discussions / C#
   

C#

 
QuestionEnterprise Library 2.0 Database Listener Pin
osamahmirza26-Jul-06 3:21
osamahmirza26-Jul-06 3:21 
Questionbackups! [modified] Pin
Jaymahinda26-Jul-06 3:17
Jaymahinda26-Jul-06 3:17 
AnswerRe: backups! Pin
Ed.Poore26-Jul-06 4:45
Ed.Poore26-Jul-06 4:45 
Questionabstract class & interface Pin
lavate malllik26-Jul-06 1:51
lavate malllik26-Jul-06 1:51 
AnswerRe: abstract class & interface Pin
leppie26-Jul-06 1:54
leppie26-Jul-06 1:54 
AnswerRe: abstract class & interface Pin
stancrm26-Jul-06 1:54
stancrm26-Jul-06 1:54 
AnswerRe: abstract class & interface Pin
J4amieC26-Jul-06 2:47
J4amieC26-Jul-06 2:47 
QuestionWhen use static method and when use non static method ? Pin
CooperWu26-Jul-06 1:47
CooperWu26-Jul-06 1:47 
Hi all,
I'm fresh man of OOP. so I want know When use static method and when use non static method ?
Any guidelines for use non static method or static method?

c# code sample:

//static method
class myclass
{
  public myclass() {}

  private int _i= 0;

  public int Value
  {
    get { return _i;}
    set {_i= value; }
  }

  public static int GetDoubleValue(int value)
  {
    return 2 * value;
  }

  // or
  public static int GetDoubleValue(myclass c)
  {
    return 2 * c.Value;
  }
}

//non static method
class myclass
{
  public myclass() {}

  private int _i= 0;

  public int Value
  {
    get { return _i;}
    set {_i= value; }
  }

  public int GetDoubleValue()
  {
    return 2 * this.Value;
  }
}

AnswerRe: When use static method and when use non static method ? Pin
Christian Graus26-Jul-06 2:07
protectorChristian Graus26-Jul-06 2:07 
GeneralRe: When use static method and when use non static method ? Pin
CooperWu26-Jul-06 2:30
CooperWu26-Jul-06 2:30 
AnswerRe: When use static method and when use non static method ? Pin
MatthysDT26-Jul-06 2:15
MatthysDT26-Jul-06 2:15 
GeneralRe: When use static method and when use non static method ? [modified] Pin
CooperWu26-Jul-06 2:58
CooperWu26-Jul-06 2:58 
AnswerRe: When use static method and when use non static method ? Pin
MartyExodus26-Jul-06 5:04
MartyExodus26-Jul-06 5:04 
GeneralRe: When use static method and when use non static method ? Pin
CooperWu26-Jul-06 19:31
CooperWu26-Jul-06 19:31 
AnswerRe: When use static method and when use non static method ? Pin
A.A.26-Jul-06 5:30
A.A.26-Jul-06 5:30 
GeneralRe: When use static method and when use non static method ? Pin
CooperWu26-Jul-06 19:36
CooperWu26-Jul-06 19:36 
QuestionDirectory.Exists fails on UNC names Pin
paas26-Jul-06 1:24
paas26-Jul-06 1:24 
AnswerRe: Directory.Exists fails on UNC names Pin
paas26-Jul-06 3:14
paas26-Jul-06 3:14 
Question[Message Deleted] Pin
waheed awan26-Jul-06 1:03
waheed awan26-Jul-06 1:03 
AnswerRe: c# compiler Pin
Christian Graus26-Jul-06 1:38
protectorChristian Graus26-Jul-06 1:38 
GeneralRe: c# compiler Pin
Paul Conrad26-Jul-06 6:22
professionalPaul Conrad26-Jul-06 6:22 
AnswerRe: c# compiler Pin
MCSD-Gandalf26-Jul-06 1:41
MCSD-Gandalf26-Jul-06 1:41 
GeneralRe: c# compiler Pin
Colin Angus Mackay26-Jul-06 4:54
Colin Angus Mackay26-Jul-06 4:54 
GeneralRe: c# compiler Pin
Paul Conrad26-Jul-06 6:24
professionalPaul Conrad26-Jul-06 6:24 
AnswerThats easy Pin
Ennis Ray Lynch, Jr.26-Jul-06 4:35
Ennis Ray Lynch, Jr.26-Jul-06 4: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.