c#: static member vs instance member
why would i need a static function, over a member function..
we know
static function/variable doesn't require an object to access
static member maintains its state across multiple object (ex: static int
couter = 0;)
but wht's the big deal in creating an object, to access a behavior of a
class... is it because i don't have to initialize memory (for an object),
when accessing a static function, thereby save some bytes of memory...
if that's the case then, where does a class definition live so that my
currently executing class can have access to it...if it lives in memory,
then y can't i create an object for the same...
is it because, object(size in memory) > class definition (size in memory)
in some cases its also said that
a function which has no impact on an instance object we need to make use
of a static function (for ex: Math related functions in System.Math) (is
that true...)
No comments:
Post a Comment