logo
 
  •  
  • Thread Rating
    70.0%
    Rate this Thread
    Double click on boxes to rate this thread
  • C# Interview Questions part2
  • Q: Whatâ..s the difference between System.String and System.StringBuilder classes
    A: System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

    Q: Whatâ..s the advantage of using System.Text.StringBuilder over System.String
    A: StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time itâ..s being operated on, a new instance is created.

    Q: Can you store multiple data types in System.Array
    A: No.

    Q: Whatâ..s the difference between the System.Array.CopyTo() and System.Array.Clone()
    A: The first one performs a deep copy of the array, the second one is shallow.

    Q: How can you sort the elements of the array in descending order
    A: By calling Sort() and then Reverse() methods.

    Q: Whatâ..s the .NET datatype that allows the retrieval of data by a unique key
    A: HashTable.

    Q: Whatâ..s class SortedList underneath
    A: A sorted HashTable.

    Q: Will finally block get executed if the exception had not occurred
    A: Yes.

    Q: Whatâ..s the C# equivalent of C++ catch (â.¦), which was a catch-all statement for any possible exception
    A: A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

    Q: Can multiple catch blocks be executed
    A: No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.

    Q: Whatâ..s a delegate
    A: A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.

    Q: Whatâ..s a multicast delegate
    A: Itâ..s a delegate that points to and eventually fires off several methods.

    Q: Howâ..s the DLL Hell problem solved in .NET
    A: Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.

    Q: What are the ways to deploy an assembly
    A: An MSI installer, a CAB archive, and XCOPY command.

    Q: Whatâ..s a satellite assembly
    A: When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

    Q: What namespaces are necessary to create a localized application
    A: System.Globalization, System.Resources.

    Q: Whatâ..s the difference between // comments, /* */ comments and /// comments
    A: Single-line, multi-line and XML documentation comments.

    Q: How do you generate documentation from the C# file commented properly with a command-line compiler
    A: Compile it with a /doc switch.

    Q: Is XML case-sensitive
    A: Yes, so and are different elements.

    Q: What debugging tools come with the .NET SDK
    A: CorDBG â... command-line debugger, and DbgCLR â... graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.

    Q: What does the This window show in the debugger
    A: It points to the object thatâ..s pointed to by this reference. Objectâ..s instance data is shown.

    Q: What does assert() do
    A: In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.

    Q: Whatâ..s the difference between the Debug class and Trace class
    A: Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.

    Q: Why are there five tracing levels in System.Diagnostics.TraceSwitcher
    A: The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.

    Q: Where is the output of TextWriterTraceListener redirected
    A: To the Console or a text file depending on the parameter passed to the constructor.

    Q: How do you debug an ASP.NET Web application
    A: Attach the aspnet_wp.exe process to the DbgClr debugger.

    Q: What are three test cases you should go through in unit testing
    A: Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).

    Q: Can you change the value of a variable while debugging a C# application
    A: Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
    By Mukund - Sep 04 2009 Reply » Save » Print »

Login to post your reply