.NET Specific Interview Question Answers

10/14/2011 No Comment
What are the Expansions of MSIL, JIT, CLR, CTS, CLS, RCW?
1. MSIL - Microsoft Intermediate Language.
2. JIT - Just-In-Time compiler .
3. CLR - Common Language Runtime.
4. CTS - Common Type System.

5. CLS - Common Language Specification.
6. RCW - Runtime Callable Wrapper.

Which NameSpace is used to get the information of events about the system, devices like Hard disk serial No, Operating System and Processor?
NOTE: This is objective type question, Please click question title for correct answer.

Which design pattern is implemented in the below code snippet? using System; public class MyClass { private static MyClass instance; private MyClass() {} public static MyClass Instance { get { if (instance == null) { instance = new MyClass(); } return instance; } } }
Posted by: Peermohamedmydeen
NOTE: This is objective type question, Please click question title for correct answer.

What is equivalent for regsvr32.exe in .NET?
In .NET we have regasm to register and unregister assemblies through .NET.

What is Covariance and Contravariance ?
Assigning a string to an object from specific type to a more general type is called covariance.

In contrast, assigning an array of objects to an array of strings, from general type to a more specific type, is referred to as contravariance.

Sorting on a Datatable
By using a datatable we can sort the data with out going for a dataview.

DataTable dt = new DataTable();
dt.Select(" select criteria if any " , " sort string ")

What is a DependencyProperty and How to implement it?
DependencyProperty is set to enable declarative code to alter the properties of an object which reduces the data requirements by providing a more powerful notification system regarding the change of data in a very specific way. In .NET, there are two types of properties. One is the normal property & another is the DependencyProperty which has added functionality over the normal property.

Now, let us discuss on how to implement such DependencyProperty to give a powerful notification on data change:

First of all, implement the UserControl class from INotifyPropertyChanged interface:

public partial class MyUserControl : UserControl, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Create your own normal Property, lets say the name of the property is “Caption”.

public string Caption
{
get { return GetValue(CaptionProperty).ToString(); }
set { SetValue(CaptionProperty, value); }
}
Now, register the DependencyProperty to the CLR by calling the Register method by passing the property field that you used to store the data in earlier step:

public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(MyUserControl), new PropertyMetadata(string.Empty, OnCaptionPropertyChanged));

The name of the identifier field of the DependencyProperty will be same as you used in the property after appending “Property” at the end. In this example, our Property name is “Caption”, hence our identifier field name is “CaptionProperty”. Add the PropertyMetaData with default value & callback event handler within the Register method as mentioned in the above code. Mark the identifier as static & readonly so that this will be unique to the CLR.

Now, implement the OnCaptionPropertyChanged event handler:

private static void OnCaptionPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
MyUserControl myUserControl = dependencyObject as MyUserControl;
myUserControl.OnPropertyChanged("Caption");
myUserControl.OnCaptionPropertyChanged(e);
}

private void OnCaptionPropertyChanged(DependencyPropertyChangedEventArgs e)
{
txbCaption.Text = Caption;
}

The implementation of the DependencyProperty is complete. You can either call it from XAML:

or from Code behind:
MyUserControl myUserControl = new MyUserControl();
myUserControl.SetValue(MyUserControl.CaptionProperty, "My First Dependency Property Example");

How can we open the disassembler from Dot Net Command prompt ?
ILDASM (Intermediate Language Disassembler) is installed along with Visual Studio. You can found it inside the Visual Studio SDK Folder.
Version folder name will be depends on your .NET Framework version.
As for Example,
C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\
Now With the help of command

ILDASM
we can open it from Visual Studio Command Prompt.
We can open the ibuilt disassembler provided with framework to check the assembly information.

Which namespace is used to create an Exception Tree?
System.Data.Common.CommandTree namespace provide classes to create an Exception Tree.

Which namespace is used to work with RSS feeds in .NET?
System.ServiceModel.Syndication namespace is used to work with RSS feeds in .NET.

Which class is the base class of all the exception classes?
System.Exception class is the base class of all the exception classes in .NET.

What is the use of System.SystemException namespace?
System.SystemException provide different classes to handle fatal as well as non fatal errors.
Related Posts


No comments :

 

Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer