Static methods in C #?

What is the performance issue with the static method on non-stationary methods? I read that static methods are better in terms of performance, but I want to know how they are faster? If the method does not use any member of the instance, then our compiler should take care of this and consider it as a static method.

+3
source share
6 answers

Edit: Eric comments more on this one here , and hints that there are several times when used call... although a note that his new()example is not guaranteed ;-p


(pre-1.1) ( this) ; , null, ..

obj.SomeMethod();

( obj=null SomeMethod, this). , - SomeMethod. (.. -, ), , , , .

, " " , SomeMethod ().

, - IL, , , , "oh no you do not!". CLR ( ); , (, ), .

+7

- . ( , , )

, ( ) - , , ?

, 3 .

+5

. .

:

4-5 .

+3

, , . . . , .

+1

,

, ,

.......

0

, , , GC , , .

- , , , .

0

Source: https://habr.com/ru/post/1725583/


All Articles