Can't I just use all static methods?
Posted
by
Reddy S R
on Programmers
See other posts from Programmers
or by Reddy S R
Published on 2011-08-02T23:20:39Z
Indexed on
2012/12/19
17:13 UTC
Read the original article
Hit count: 393
object-oriented
|static-methods
What's the difference between the two UpdateSubject methods below? I felt using static methods is better if you just want to operate on the entities. In which situations should I go with non-static methods?
public class Subject
{
public int Id {get; set;}
public string Name { get; set; }
public static bool UpdateSubject(Subject subject)
{
//Do something and return result
return true;
}
public bool UpdateSubject()
{
//Do something on 'this' and return result
return true;
}
}
I know I will be getting many kicks from the community for this really annoying question but I could not stop myself asking it.
Does this become impractical when dealing with inheritance?
© Programmers or respective owner