- Home /
how faster is Static Function
correct me if I'm wrong
if static means only 1 does it make take less space and is it more good for performance?
what takes less RAM / HDD
variable
constant variable
static constant variable
Answer by fafase · Jan 27, 2013 at 06:31 PM
Static is slightly faster than instance for one reason. Every time you call something like
myObj.itsVariable;
The compiler needs first to make sure the instance exists while a static is sure to exist.
Look there http://www.dotnetperls.com/callvirt
wow so pretty much aloot
if there are total 9 lines to do
and if static only 5 lines it makes 44% faster but humh not always can be used static
44% might be a little too much. Even though there are less lines, the benchmark done on the link shows 1.23% due to the callvirt function. Still, static is slightly faster. As for where to use static, yes, you need to make sure is is right.