C Sharp Interview Questions
C# and Dot Net Interview Questions
What is the use of fixed statement
The fixed statement sets a pointer to a managed variable and “pins” that variable during the execution of statement.
Without fixed, pointers to managed variables would be of little use since garbage collection could relocate the variables unpredictably. (In fact, the C# compiler will not allow you to set a pointer to a managed variable except in a fixed statement.)
Eg: Class A { public int i; }
A objA = new A; // A is a .net managed type
fixed(int *pt = &objA.i) // use fixed while using pointers with managed
C# and Dot Net Interview Questions VI
Which class use to Read/Write data to memory
MemoryStream
It is a nonbuffered stream whose encapsulated data is directly accessible in memory(RAM not files on disk).
To Configure .Net for JIT activation what do you do
Actually JIT activation is required for COM+ components which can be done by setting JustInTimeActivation attribute to true (choice A). For .net applications / components JIT comes in by default.
Which method is used by COM+ to ascertain whether class can be pooled
CanBePooled
How do you import Activex component in to .NET
C# and Dot Net Interview Questions I
Where does the version dependencies recorded
Inside an assembly’s manifest
How do you refer parent classes in C#
This keyword is used for reffering current object and Base keyword is used for referring parrent class. so ans. is C
Which attribute you generally find on top of main method
[ STAThread ]
How do you make a class not instantiable
Making class as Abstract
In a multilevel hierarchy how are the constructors are called
TopDown
C# and Dot Net Interview Questions V
Which method is actually called ultimately when Console.WriteLine( ) is invoked
AppendFormat() method is called.
What happens when you create an arraylist as ArrayList Arr=new ArrayList()
Once it will reach size 16 addding element in the arraylist, it will be automatically double the size.
What is the output of Vectors.RemoveAt(1)
Removes the object at position 1
GetEnumerator( ) of Ienumerable interface returns
GetEnumerator() returns a reference to System.Collections.Ienumerator class which allows a simple iteration over a collection
How do you add objects to hashtable
C# and Dot Net Interview Questions IV
Which method is implicitly called when an object is created
When an object is created Constructor is get called first. A default constructor is created automatically if we do not create a constructor inside a class.
Which of the following statement is invalid with regards to constructor
Constructors should have the same name as class name
Constructors have to be public so that class can be instantiated
Constructors can not be overloaded
Constructors can not be static
C# supports two types of constructor, a class constructor (static constructor) and an instance constructor (non-static constructor).