Tuesday, October 14, 2008

How can I access the registry from C# code?

By using the Registry and RegistryKey classes in Microsoft.Win32, you can easily access the registry.

The following is a sample that reads a key and displays its value:using System;using Microsoft.Win32;

class regTest{

public static void Main(String[] args)

{

RegistryKey regKey;

Object value;

regKey = Registry.LocalMachine;

regKey =regKey.OpenSubKey("HARDWAREDESCRIPTIONSystemCentralProcessor ");

value = regKey.GetValue("VendorIdentifier");

Console.WriteLine("The central processor of this machine is: {0}.", value);}}



How can you sort the elements of the array in descending order?

By calling Sort() and then Reverse() methods.



How do you debug an ASP.NET Web application?

Attach the aspnet_wp.exe process to the DbgClr debugger.



How do you mark a method obsolete?

Assuming you've done a "using System;": [Obsolete]

public int Foo()

{...}

or [Obsolete("This is a message describing why this method is obsolete")]

public int Foo() {...}

Note: The O in Obsolete is capitalized.

INTERVIEW QUESTIONS-23 POST...