Tanzeel Tanzeel - 1 year ago 88
C# Question

How does CLR manage when a static method is called?

I have static class having static methods as shown below:

public static StaticTest
public static void DoSomeWork()
/// Do Some work

function is called, how does CLR manage the function references as it is obvious that an instance of static class cannot be created?

What is the mechanism behind the scene to call the function in this case?

Answer Source

When the CLR loads an assembly containing static members, those members are placed in a dedicated space in memory called High Frequency Heap. Objects in the High-Frequency Heap are never Garbage collected to make sure that the static variables are available throughout the lifetime of the application.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download