Interview FAQs


FAQs of level

Use the using directive to create an alias for a long namespace or class. The using alias has a scope within the namespace you declare it in.

// Namespace:
using act = System.Runtime.Remoting.Activation;

// Class:
using list = System.Collections.ArrayList;

list l = new list(); // Creates an ArrayList
act.UrlAttribute obj; // Equivalent to System.Runtime.Remoting.Activation.UrlAttribute obj

Inheritance is the mechanism which allows a class A to inherit properties of a class B. We say "A inherits from B". Objects of class A thus have access to attributes and methods of class B without the need to redefine them.

If class A inherits from class B, then B is called superclass of A. A is called subclass of B. Objects of a subclass can be used where objects of the corresponding superclass are expected. This is due to the fact that objects of the subclass share the same behavior as objects of the superclass.

Before C# 2.0, the only way to use delegates was to use named methods. In some cases, this results in forced creation of classes only for using with delegates. In some cases, these classes and methods are never even invoked directly.

C# 2.0 offers an elegant solution for these methods described above. Anonymous methods allow declaration of inline methods without having to define a named method. This is very useful, especially in cases where the delegated function requires short and simple code. Anonymous methods can be used anywhere where a delegate type is expected.

Anonymous Method declarations consist of the keyword delegate, an optional parameter list and a statement list enclosed in parenthesis.

Code Snippet: Event Handler (without using anonymous methods)

btnSave.Click += new EventHandler (btnSave_Click);

void AddClick(object sender, EventArgs e)
lblStatus.Text = "Your changes have been saved";

Code Snippet: Event Handler (using anonymous methods)

btnSave.Click += delegate { SaveChanges(); lblStatus.Text = "Your changes have been saved"; };

Code Snippet: Event Handler using Anonymous Methods, with a parameter list

btnSave.Click += delegate(object sender, EventArgs e)
MessageBox.Show("Your changes have been saved");

Anonymous methods can be used in the place where there is a use of a delegate. To understand anonymous methods we should understand the usage of delegate first.
We can reduce the code by preventing delegate instantiation and registering it with methods. It increases the readability and maintainability of our code by keeping the caller of the method and the method itself as close to one another as possible.
The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is formed & the start address is changed. Thus keeping the old string in memory for garbage collector to be disposed.
By searching directory paths. There are several factors which can affect the path (such as the AppDomain host, and application configuration files), but for private assemblies the search path is normally the applications directory and its sub-directories. For shared assemblies, the search path is normally same as the private assembly path plus the shared assembly cache.
A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated. Visual Studio .NET IDE has a utility under the tools menu to generate GUIDs.
Encapsulation is the ability to hide the internal workings of an objects behaviour and its data. For instance, lets say you have a object named Bike and this object has a method named start(). When you create an instance of a Bike object and call its start() method you are not worried about what happens to accomplish this, you just want to make sure the state of the bike is changed to running afterwards. This kind of behaviour hiding is encapsulation and it makes programming much easier.
Just-In-Time compiler- it converts the language that you write in .Net into machine language that a computer can understand. There are two types of JITs one is memory optimized & other is performance optimized.
PreviousDisplaying 14 of 25Next
Need Help? Contact Us.

Log in


Forgot password?


New User