C # - Static class call means "content by address?"

I just have a bit of confusion about understanding a static link.

instance link expression that we can understand when I declare

Car myCar = new Car();

Car yourCar = new Car();

---------------                       --------------
stack                                 Managed Heap
----------------                      --------------
                                        -----
myCar         ------- > points to       Car
                                        -----
YourCar       ------- > points to       Car
                                        -----

-----------------                     ---------------

What if a case of a Static class? can i say this when i announce

staticClass.MyMethod( )

-----------------
Managed Heap
----------------
staticClass
(Memory Address ) 
----------------- 

Update: Since the class is a plan and the objects are physical objects, does a static class occur when I declare staticClass.MyMethod or staticClass.MyField = value, do I interact directly with the heap? (Since an instance is not allowed for a static class).

+5
source share
2 answers

No, staticin C # it basically means "referring to the type, not an instance of the type."

- -

StaticClass.MyMethod()

, - . , ( ).

, , .

EDIT: . , , , :

StaticClass.StaticMethod();

NormalClass.StaticMethod();

SomeValueType.StaticMethod();

EDIT: :

  • , , , , gen0/gen1/gen2. ( , AppDomain , .)
  • , JIT, . , , , .

EDIT: , " ", , AppDomain. , AppDomain. .

+11

. - , . , OO, . ( .)

0

All Articles