-
What is the equivalent to regsvr32 and regsvr32 /u a file in .NET development?
Try using RegAsm.exe. The general syntax would be: RegAsm. A good description of RegAsm and its associated switches is located in the .NET SDK docs. Just search on "Assembly Registration Tool".
-
How can I get around scope problems in a try/catch?
If you try to instantiate the class inside the try, it'll be out of scope when you try to access it from the catch block. A way to get around this is to do the following: Connection conn = null; try {conn = new Connection();conn.Open();}finally{ if (conn != null) conn.Close(); }By setting it to null before the try block, you avoid getting the CS0165 error (Use of possibly unassigned local variable...
-
Why do I get a security exception when I try to run my C# app?
Some security exceptions are thrown if you are working on a network share. There are some parts of the frameworks that will not run if being run off a share (roaming profile, mapped drives, etc.). To see if this is what's happening, just move the executable over to your local drive and see if it runs without the exceptions. One of the common exceptions thrown under these conditions is System.Security.SecurityException.To...
-
How do I register my code for use by classic COM clients?
Use the regasm.exe utility to generate a type library (if needed) and the necessary entries in the Windows Registry to make a class available to classic COM clients. Once a class is registered in the Windows Registry with regasm.exe, a COM client can use the class as though it were a COM class.
-
How do you specify a custom attribute for the entire assembly (rather than for a class)?
Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows: using System;[assembly : MyAttributeClass]class X {}Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.
-
How do I declare inout arguments in C#?
The equivalent of inout in C# is ref. , as shown in the following example: public void MyMethod (ref String str1, out String str2) {...}When calling the method, it would be called like this: String s1;String s2;s1 = "Hello";MyMethod(ref s1, out s2);Console.WriteLine(s1);Console.WriteLine(s2);Notice that you need to specify ref when declaring the function and calling it.
-
How do I simulate optional parameters to COM calls?
You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.
-
Is it possible to Override Private Virtual methods
A) YesB) NoC) Either A or BD) None
-
Which method is used by COM+ to ascertain whether class can be pooled
A) Pooled( )B) IsPooled( )C) CanbePooled( )
-
To Configure .Net for JIT activation what do you do
A) Set JustinTimeActivation attribute to TrueB) Set JustinTimeActivation attribute to FalseC) None
-
What is the advantage of using System.Text.StringBuilder over System.String?
StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it is being operated on, a new instance is created.
-
What is the difference between System.String and System.StringBuilder classes?
System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
-
Where is the output of TextWriterTraceListener redirected?
To the Console or a text file depending on the parameter passed to the constructor.
-
Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
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.
-
What does the This window show in the debugger?
It points to the object that is pointed to by this reference. Object’s instance data is shown.
-
What debugging tools come with the .NET SDK?
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.
-
What is the difference between and XML documentation tag?
Single line code example and multiple-line code example.
-
What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it is a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.
-
Explain ACID rule of thumb for transactions.
Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasnot), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system...
-
What connections does Microsoft SQL Server support?
Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).
C# Interview Questions
Ans