Can we force garbage collector to run
We can force the garbage collector to run using gc.collect() method
What is reflection
The method of getting metadata information like type, modules, methods information from an assembly is known as reflection. reflection classes are grouped inside system.reflection namespace. reflection is also used to dynamically invoke methods inside a class.
What are different types of jit
Just in time compiler is known as jit and there are three different types of jit in .net
1) enco jit - econo-jit compiles a method only when it is called while execution and after the execution it removes this compiled method from memory
2) pre – jit- pre – jit compiles the entire code to msil during the time of deployment. complete compilation happens in one cycle
3) normal jit - normal jit compiles a method only when it is called. the main difference between enco jit and normal jit is, normal jit caches the compiled code in memory which is known as jitted. when a method called again it will use this cached code from memory
What are value types and reference types
A value type stores the values in its own memory location where as a reference type stores a pointer to another memory location where the memory is actually stored. value type variables are stored in a stack and reference type variables are stored in a heap.
examples of value type –
boolean, numeric data types like int, long etc., char, structures, enumerations
examples of reference type –
string, arrays, class, delegates
What is boxing and unboxing
The process of converting a value type to reference type is known as boxing and the process of converting a reference type to value type is known as unboxing.
the below code illiterates boxing and unboxing
int ivaluetype = 10;
object oreferencetype = ivaluetype; //boxing
ivaluetype = (int) oreferencetype; //unboxing
What is the difference between system exceptions and application
System exceptions - exceptions which are thrown by the clr are known as system exceptions. examples like stackoverflowexception, dividebyzeroexception etc.
application exceptions - user defined exceptions are known as application exceptions. they are derived from ystem.applicationexception. example
throw new applicationexception(“age should not be less than zero”)