Friday, January 30, 2009

C# FAQs-1

1. What is MSIL?
Microsoft Intermediate Language (MSIL) is the CPU-independent instruction set generated by .NET compilers from .NET languages such as J#, C# or Visual Basic. MSIL is compiled before or during execution of the program by a Virtual Execution System (VES), which is part of the Common Language Runtime module (CLR).

2. What is the CLR and how is it different from a JVM?
The JVM can either interpret or just-in-time compile the byte code. The CLR always compiles to native code. Another is that the CLR supports unmanaged code, known as “unsafe”, where the programmer assumes the responsibility for managing memory and can do pointer arithmetic and so forth.

3. What is WinFX?
The new Windows API that will be released with the Microsoft Longhorn Operating System. This will include features for Avalon, Indigo, and WinFS as well as a number of fundamental routines.

4. What is Indigo?
The code name for the communications portion of Longhorn that is built around Web services. This communications technology focuses on providing spanning transports, security, messaging patterns, encoding, networking and hosting, and more.

5. Explain the Remoting architecture.
From http://www.kippsoftware.com/san200405.htm
· The developer first instantiates locally a proxy interface to the remote assembly. Local code calls a method of the proxy
· The .NET platform calls the corresponding method on the remote server and returns the results (see figure).
· Developers can use TCP or HTTP remoting.
· Remoting makes use of Leases and allocations to improve efficiency.

6. How would you write an asynchronous webservice?
Use a callback and call BeginSubmit yourself.

7. What is the Microsoft Enterprise Library?
A set of functions that adhere to Microsoft’s Patterns and Practices guidelines. These functions include:
Caching Application Block, Configuration Application Block, Data Access Application Block, Cryptography Application Block, Exception Handling Application Block, Logging and Instrumentation Application Block and the Security Application Block.
8. Discuss System.Collections
8 – 24 From http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollections.asp
The System.Collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hashtables and dictionaries.
9. Discuss System.Configuration
The System.Configuration namespace provides classes and interfaces that allow you to programmatically access .NET Framework configuration settings and handle errors in configuration files (.config files).
10. Discuss System.Data
The System.Data namespace consists mostly of the classes that constitute the ADO.NET architecture.
11. Discuss System.Diagnostics
The System.Diagnostics namespace provides classes that allow you to interact with system processes, event logs, and performance counters.
12. Discuss System.DirectoryServcies
The System.DirectoryServices namespace provides easy access to Active Directory from managed code.
13. Discuss System.Drawing
The System.Drawing namespace provides access to GDI+ basic graphics functionality.
14. Discuss System.EnterpriseServices
The System.EnterpriseServices namespace provides an important infrastructure for enterprise applications. COM+ provides a services architecture for component programming models deployed in an enterprise environment. This namespace provides .NET objects with access to COM+ services making the .NET Framework objects more practical for enterprise applications.
15. Discuss System.Globalization
The System.Globalization namespace contains classes that define culture-related information, including the language, the country/region, the calendars in use, the format patterns for dates, currency, and numbers, and the sort order for strings.
16. Discuss System.IO
The System.IO namespace contains types that allow reading and writing to files and data streams, and types that provide basic file and directory support.
17. Discuss System.Net
The System.Net namespace provides a simple programming interface for many of the protocols used on networks today.
18. System.Runtime contains System.Runtime.CompilerServcies, what else?
CompilerServices, InteropServices, Remoting, Serialization.
19. Discuss System.Security
The System.Security namespace provides the underlying structure of the common language runtime security system, including base classes for permissions.
20. Discuss System.Text
The System.Text namespace contains classes representing ASCII, Unicode, UTF-7, and UTF-8 character encodings; abstract base classes for converting blocks of characters to and from blocks of bytes; and a helper class that manipulates and formats String objects without creating intermediate instances of String.
21. Discuss System.Threading
The System.Threading namespace provides classes and interfaces that enable multithreaded programming.
22. Discuss System.Web
The System.Web namespace supplies classes and interfaces that enable browser-server communication.
23. Discuss System.Windows.Forms
The System.Windows.Forms namespace contains classes for creating Windows-based applications.
24. Discuss System.XML
The System.Xml namespace provides standards-based support for processing XML.
25. Does VS.NET 2003 have a web browser (think about it)?
Yes
26. How are VB.NET and C# different?
Different syntax, no unsafe VB.NET code, VB.NET is case insensitive, etc.
27. Contrast .NET with J2EE.
Overview

J2EE is a set of non-vendor specific standards for developing “fat” and “thin” applications and services, J2EE is mainly directed at “thin” clients. These standards are the collaborative effort of more than 400 companies.
.net is a tangible set of software and services designed to run on the Windows platform. The .net software and services also allow the design and implementation of enterprise and non-enterprise applications. Equal emphasis has been given to “fat” and “thin” clients. .net was developed exclusively by Microsoft.

Virtual Machines

Both .net and J2EE use a Virtual Machine to interpret intermediate code. With J2EE this intermediate code is called “Byte Code”. With .net the code is called the “Intermediate Language”. When Java or .net code is written and compiled it compiles to intermediate code.

With J2EE the JVM (Java Virtual Machine) interprets its byte code line by line into the machine’s native language. J2EE byte code can be compiled directly to native machine code or JIT (Just In Time) compiled, but the vast majority of J2EE applications are interpreted.
The .NET virtual machine, the CLR (Common Language Runtime) uses a JIT compiler to compile blocks of IL code into native machine code at run time. Visual Studio.net can also compile directly to native code.

Programming Languages

Both platforms have the option of using multiple programming languages for an enterprise application, although this is a much easier task to achieve with the .net platform.

The J2EE standard is based on Java, so applications are mainly developed in Java. Interoperability is possible through JNI (Java Native interface) and CORBA (Common Object Request Broker Architecture). The latter is almost never done as the APIs are complicated and time consuming.
.net supports the seamless integration of over 20 languages, this is done via strong typing, common interfaces and a concept called “managed code”. On the down side, the language differences are largely semantic (VB.NET vs. C#). Also, languages like C++ require extra imports (managed extensions).

Operating Systems

Both .NET and J2EE have pretensions to having portable source code.

J2EE is by far the best for portability, the whole specification is designed as to be non-vendor specific. In practice though, Java source is often not portable without modifications.
.net has promised that the CLR and core languages like C# will eventually be portable. At present .net only runs on Windows.

J2EE versus .net at Each Tier

An enterprise application can be logically separated into 3 tiers - Presentation, Business Logic, and the Data tier.

Presentation Tier

Both .net and J2EE use a scripting language at the presentation tier for “thin” clients or “Web Applications”. They also have similar ways of generating this tier for “fat” client applications.

For “thin” client applications J2EE uses Java Servlets and a derivative of ASP (Active Server Pages) called JSP (Java Server Pages), which intermingles HTML with Java based script. Calls to Business logic components (EJB - Enterprise Java Beans) are made from these JSP pages. Coding the page to render on a number of different “thin” clients must be done manually. For “fat” clients there is the Java Swing API, with a set of standard java beans and a number of different GUIs to build applications with.

.net uses Visual Studio.net for both “thin” and “fat” clients. .net “thin” client applications use the ASP.NET scripting language. ASP.NET can be used in the traditional script based way, but Microsoft encourages the use of a “Code Behind Page”. One simply drags and drops various “Web Controls” onto an ASP.NET (.aspx) page and then uses the code behind page to adjust those controls programmatically. When an .aspx page is requested by a “thin” client the page is rendered automatically by the .net runtime which checks the type of “thin” client and adjusts each control accordingly. The result is that an .aspx page can render on any supported “thin” client without any extra work. This has a down side, that being that the look n’ feel of each page is limited by the controls offered. Microsoft’s IIS server also has legacy support for ASP, so ASP.NET and ASP can be used in conjunction with each other. For “fat” clients the process is the same except that there is a different set of controls for a “Windows Form” (as opposed to a “Web Form”).

Business Logic Tier

The two technologies are very similar on this level with each borrowing concepts from the other.


Java Beans are the basic components (defined properties, event handling and persistence). EJB are the distributed equivalents that have extra functions for application level security, distributed transactions, life cycle management and resource pooling. The java runtime handles the life cycle of each component, deciding when to destroy a component (garbage collection) and what memory it can access (sandbox security).

.net uses an enriched version of COM+ (assemblies) which gives its components all of the above functions with the addition of newer concepts like extensible meta-data for each assembly. Like J2EE the “registration” of components is much easier with a new deployment model and .net projects also support traditional COM and COM+ components. Perhaps the biggest difference is the ability to go into “unmanaged mode” which allows the application to access areas of memory normally inaccessible via the CLR Sandbox.

Data Tier

For relational database access J2EE uses JDBC (Java Database Connection) – which is based on Microsoft’s ODBC (Open Database Connectivity). At a higher level it is conceptually the same as ADO (ActiveX Data Objects - which sits on top of ODBC) with connections, statements and Result sets. JDBC does perform better than ADO. For Naming and Directory Services J2EE uses JNDI (Java Naming and Directory Interface) and JDBC does not support hierarchical Database access.

.net uses ADO.NET , it has all the ADO functionality and more. All data transmission from source to component is now done via XML (eXtensible Markup Language). This means that ADO.NET can use ANYTHING that emits XML data in the ADO.NET schema as a data source. ADO.NET supports hierarchical data access, and naming and directory services are accessed via ADSI (Active Directory Services Interface).

XML, Web Services, and Remoting

Web services and remoting are web and TCP/IP based remotely callable functions that sit on top of a predetermined protocol.

J2EE’s web services run with a host of different protocols. They run with HTTP, RMI/JRMP (Remote Method Invocation / Java Remote Method Protocol) or IIOP (Internet InterORB Protocol).
.net web services run exclusively on HTTP with a SOAP (Simple Object Access Protocol) wrapper. All data interchange is done with XML. Web services in .net are all standardised with XML interfaces. Remoting uses either SOAP or TCP/IP directly. The entire .net framework is very XML centric.

Performance

In an enterprise environment .net outperforms J2EE. Benchmarks show that it is more scalable, efficient, faster to run and develop, easier to use and cheaper - sometimes by a factor of five. .net is designed to work just as well in a non-enterprise environment (pointers, unmanaged code, etc.). J2EE is rarely used in a non-enterprise environment to write graphically or numerically intensive code for executables.
28. What benefit do you have by implementing IDisposable interface in .NET?
You can use Dispose to clean up unmanaged resources.
29. Explain the difference between the Application object and Session object in ASP.NET.
The Application object affects all users of the application whereas a session only affects one (the session holder).
30. Explain the difference between User controls and Custom controls in ASP.NET.
From http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconwebusercontrolsvscustomwebcontrols.asp
Web user controls
Web custom controls
Easier to create
Harder to create
Limited support for consumers who use a visual design tool
Full visual design tool support for consumers
A separate copy of the control is required in each application
Only a single copy of the control is required, in the global assembly cache
Cannot be added to the Toolbox in Visual Studio
Can be added to the Toolbox in Visual Studio
Good for static layout
Good for dynamic layout

31. Write code for transaction control in ADO.NET.
string connectionString = ".........";
SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open();

// Start transaction.
SqlTransaction myTransaction = myConnection.BeginTransaction();

// Assign command in the current transaction.
SqlCommand myCommand = new SqlCommand();
myCommand.Transaction = myTransaction;
try
{
//db ops here.
myTransaction.Commit();
Console.WriteLine("Records are modified in the database.");
}
catch(Exception e)
{
myTransaction.Rollback();
Console.WriteLine(e.ToString());
Console.WriteLine("Neither record was written to database.");
}
finally
{
myConnection.Close();
}
32. Write code for transaction control in SQL Server.
BEGIN TRAN A
UPDATE mytable
BEGIN TRAN B WITH MARK
UPDATE mytable2
SELECT * frommytable
COMMIT TRAN B
UPDATE mytable3 ...
33. In .NET, what is an application domain?
From (Google Web Definitions)
A secure unit of processing that the Common Language Runtime uses to provide isolation between applications.
34. In SQL Server, what is an index?
An index is a list of sorted record pointers based on a column. Having indexes on your database tables will speed up SELECT queries if it is properly applied. Indexes will take up some disk space and will slow down INSERT and UPDATE queries.
35. What is optimistic vs. pessimistic locking?
Optimistic locking -- that's where you assume things will go well and design your locks so that they handle conflicts as the exceptional case
Pessimistic locking -- the converse where you assume conflicts are likely and create some kind of reservation system where sections are locked while they are edited

36. What is the difference between a clustered and non-clustered index.
From http://www.dotnetspider.com/technology/kbpages/1140.aspx
- The difference is that, Clustered index is unique for any given table and we can have only one clustered index on a table. The leaf level of a clustered index is the actual data and the data is resorted in case of clustered index.Whereas in case of non-clustered index the leaf level is actually a pointer to the data in rows so we can have as many non-clustered indexes as we can on the db.
37. In terms of remoting what is CAO and SAO?
Server Activated Objects : Stateless - SinglecallThis object type is the most prevalent and is recommended by Microsoft for use as the primary remoting type. Server activated Singlecall objects hold no state, which makes them ideal for use with clustered web servers, object pooling, and all other sorts of useful things. Since there is no state held in the object, you have to pass all the data that the object needs to do its work on every call.Server Activated Objects : Stateful - SingletonThese objects are used when you need both a stateful object AND you need that objects data to persist over time and multiple instantiation. If 3 computers instance an SAO Singleton on a server, they will all get a reference to that same object. Singletons are commonly used to direct access to scarce resources and should generally be avoided when possible.Client Activated Objects : StatefulCAO Objects are used when you need an object to be stateful throughout its lifetime to its caller. CAO Objects persist data to their caller, however they are different from SAO Singletons in that multiple instantiations of a CAO will get brand new instances of that CAO each time.
38. Remoting uses MarshallByRefObject, what does this mean?
A reference is returned to the remote object.
39. Write some code to use reflection, remoting, threading, and thread synchronization.
Threads and remoteable object:
using System;
using System.Reflection;
using System.Threading;

namespace Example
{
public class allThreads
{
const int NUMBER_OF_OPS = 10;
const int SLEEP_TIME = 2000;

private int threadNumber;
static int threadGlobalDS;
static object lockVariable = "dummy";

public allThreads(int threadNumber)
{
this.threadNumber = threadNumber;
}

// Thread with critical data access section using lock and global object

public void threadMethod()
{
System.Console.WriteLine("Thread " + threadNumber.ToString() + " starting with Hashcode: " + Thread.CurrentThread.GetHashCode());
System.Console.WriteLine("------------------");

for (int i=1;i<=NUMBER_OF_OPS;i++) { System.Console.WriteLine("--> Thread " + threadNumber.ToString() + " performing operation " + i.ToString());
}

System.Console.WriteLine("--> Thread " + threadNumber.ToString() + " sleeping");
Thread.Sleep(SLEEP_TIME);

// Locking using a global variable
lock(lockVariable)
{
System.Console.WriteLine("--> Thread " + threadNumber.ToString() + " has a lock");

// Access critical data
threadGlobalDS = threadNumber;

System.Console.WriteLine("--> Thread " + threadNumber.ToString() + " sleeping");
Thread.Sleep(SLEEP_TIME);
}

System.Console.WriteLine("--> Thread " + threadNumber.ToString() + " sleeping");
Thread.Sleep(SLEEP_TIME);
}
}

// Producer and consumer example using Monitor

public class monitorThreads
{
const int SLEEP_TIME = 2000;
const int MAX_PRODUCED = 5;

private static int threadGlobalDS = 0;
private static int bufferCount = 1;
private static bool producing = true;
private static bool consuming = true;

public void monitorMethod1()
{
// Producer...

while(producing)
{
// Synch using monitor

/* Attempt to get an exclusive lock on this object
* Block otherwise */
Monitor.Enter(this);

if(bufferCount == 1)
{
/* Release the lock on this object and block
* the current thread until it reacquires the lock. */
Monitor.Wait(this);
}
threadGlobalDS +=1;

++bufferCount;

if (threadGlobalDS == MAX_PRODUCED)
{
producing = false;
}
/* Notify a thread in the waiting
* queue of a change in the locked object's state (this object). */
Monitor.Pulse(this);

// Releases the exclusive lock on this object.
Monitor.Exit(this);

System.Console.WriteLine("--> Producer sleeping");
Thread.Sleep(SLEEP_TIME);
}
}

public void monitorMethod2()
{
while(consuming)
{
// Consumer...

// Synch using monitor
Monitor.Enter(this);

if(bufferCount == 0)
{

Monitor.Wait(this);
}

--bufferCount;
System.Console.WriteLine("--> Consumed " + threadGlobalDS.ToString());

Monitor.Pulse(this);
Monitor.Exit(this);

if (!producing)
{
consuming = false;
}
}
}
}

// Class to be remoted

public class RemotingLoader : System.MarshalByRefObject
{

public RemotingLoader()
{
System.Console.WriteLine("New Client Added");
}

public SomeMetadata GetSomeMetadata(decimal userID)
{
// Create objects to thread
allThreads threadObj1 = new allThreads(1);
allThreads threadObj2 = new allThreads(2);
allThreads threadObj3 = new allThreads(3);

// Instanciate and spin off some of threads
Thread thread1 = new Thread(new ThreadStart(threadObj1.threadMethod));
Thread thread2 = new Thread(new ThreadStart(threadObj2.threadMethod));
Thread thread3 = new Thread(new ThreadStart(threadObj3.threadMethod));

thread1.Start();
thread2.Start();
thread3.Start();

// Show that thread1 is alive
if (thread1.IsAlive)
{
System.Console.WriteLine("*-> Thread 1 is alive");
}

// Abort thread1 and check again
thread1.Abort();

if (!thread1.IsAlive)
{
System.Console.WriteLine("*-> Thread 1 is dead");
}

// Monitor example
monitorThreads monitorObj = new monitorThreads();

// Instanciate and spin off some of threads
Thread monitorThread1 = new Thread(new ThreadStart(monitorObj.monitorMethod1));
Thread monitorThread2 = new Thread(new ThreadStart(monitorObj.monitorMethod2));

monitorThread1.Start();
monitorThread2.Start();

monitorThread1.Join();
monitorThread2.Join();
thread1.Join();
thread2.Join();
thread3.Join();

System.Console.WriteLine("*-> Finished");

return new SomeMetadata(1);
}
}

// Class to be serialized

[Serializable]
public class SomeMetadata
{
public Type objectType;
public ConstructorInfo [] info;
public MethodInfo [] methods;

private string objectName;

decimal remoteObjectID;

public SomeMetadata(decimal remoteObjectID)
{
objectType = this.GetType();
info = objectType.GetConstructors();
methods = objectType.GetMethods();
this.remoteObjectID = remoteObjectID;
}

public String Name
{
get { return objectName; }
set
{ this.objectName = value; }
}
}
}
Server
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

namespace Example
{
public class RemotingServer
{
public static void Main(String[] args)
{
// Register Channel
TcpServerChannel channel = new TcpServerChannel(9000);
ChannelServices.RegisterChannel(channel);

// Register Service Type
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingLoader),
"RemotingLoader", WellKnownObjectMode.SingleCall);

// Wait
System.Console.WriteLine("Press Any Key To Kill The Server");
System.Console.ReadLine();
}
}
}
Client
using System;
using System.Reflection;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

namespace Example
{
public class RemotingClient
{
public static void Main(string[] args)
{
// Register channel and point to remote object
ChannelServices.RegisterChannel(new TcpClientChannel());
RemotingLoader loader = (RemotingLoader)Activator.GetObject(
typeof(RemotingLoader), "tcp://localhost:9000/RemotingLoader");

// Get a reference to the remote object
SomeMetadata objReference = loader.GetSomeMetadata(1);

// Display data from object
Console.WriteLine("");
Console.WriteLine("*--- Object Type ---*");
Console.WriteLine("");

Console.WriteLine(objReference.objectType);

Console.WriteLine("");
Console.WriteLine("*--- Constructor Info. ---*");
Console.WriteLine("");

foreach(ConstructorInfo consInfo in objReference.info)
{
Console.WriteLine(consInfo);
}

Console.WriteLine("");
Console.WriteLine("*--- Method Info. ---*");
Console.WriteLine("");

foreach(MethodInfo methodInfo in objReference.methods)
{
Console.WriteLine(methodInfo);
}

Console.WriteLine("");
Console.WriteLine("*--- Setting and getting a Remote Variable. ---*");
Console.WriteLine("");

objReference.Name = "Test Name";
Console.WriteLine(objReference.Name);

// Wait...
Console.ReadLine();
}
}
}


Misc

1. Can you prevent your class from being inherited by another class?
Yes. The keyword “sealed” will prevent the class from being inherited.
2. Explain the three tier or n-Tier model.
Presentation (UI), business (logic and underlying code) and data (from storage or other sources).
3. What is SOA?
Service Oriented Architecture. In SOA you create an abstract layer that your applications use to access various "services" and can aggregate the services. These services could be databases, web services, message queues or other sources. The Service Layer provides a way to access these services that the applications do not need to know how the access is done. For example, to get a full customer record, I might need to get data from a SGL Server database, a web service and a message queue. The Service layer hides this from the calling application. All the application knows is that it asked for a full customer record. It doesn't know what system or systems it came from or how it was retrieved.
4. Is XML case-sensitive?
Yes
5. Can you explain some differences between an ADO.NET Dataset and an ADO Recordset? (Or describe some features of a Dataset).
A DataSet can represent an entire relational database in memory, complete with tables, relations, and views. A DataSet is designed to work without any continuing connection to the original data source. Data in a DataSet is bulk-loaded, rather than being loaded on demand. There's no concept of cursor types in a DataSet. DataSets have no current record pointer You can use For Each loops to move through the data. You can store many edits in a DataSet, and write them to the original data source in a single operation. Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.
ASP.NET
1. Explain the differences between Server-side and Client-side code?
Server-side code executes on the server. Client-side code executes in the context of the clients' browser.
2. What does the "EnableViewState" property do? Why would I want it on or off?
It allows page objects to save their state in a Base64 encoded string in the page HTML. One should only have it enabled when needed because it adds to the page size and can get fairly large for complex pages with many controls. (It takes longer to download the page).
3. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?
Server.Transfer transfers excution directly to another page. Response.Redirect sends a response to the client and directs the client (the browser) to load the new page (it causes a roundtrip). If you don't need to execute code on the client, Transfer is more efficient.
4. What base class do all Web Forms inherit from?
The Page class (System.Web.UI.Page).
5. What does WSDL stand for? What does it do?
(Web Services Description Language). It describes the interfaces and other information of a web service.
6. Which WebForm Validator control would you use if you needed to make sure the values in two different WebForm controls matched?
CompareValidator Control.
7. What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?
You must set the DataSource property and call the DataBind method.


1. What is a satellite Assembly?
An assembly containing localized resources for another assembly.
2. In Object Oriented Programming, how would you describe encapsulation?
The separation of interface and implementation.
* Encapsulation describes the ability of an object to hide its data and methods from the rest of the world. (Google web definitions).

1. Can you store multiple data types in System.Array?
No.
2. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The first one performs a deep copy of the array, the second one is shallow. A shallow copy of an Array copies only the elements of the Array, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new Array point to the same objects that the references in the original Array point to. In contrast, a deep copy of an Array copies the elements and everything directly or indirectly referenced by the elements.
3. How can you sort the elements of the array in descending order?
By calling Sort() and then Reverse() methods.
4. What’s the .NET collection class that allows an element to be accessed using a unique key?
HashTable.
5. What class is underneath the SortedList class?
A sorted HashTable.
6. Will the finally block get executed if an exception has not occurred?­
Yes
7. Can you prevent your class from being inherited by another class?
Yes. The keyword “sealed” will prevent the class from being inherited
8. If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?
Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.
9. What’s a multicast delegate?
(See the first set of answers)
10. What’s the difference between // comments, /* */ comments and /// comments?
Single-line comments, multi-line comments, and XML documentation comments.
11. How do you generate documentation from the C# file commented properly with a command-line compiler?
Compile it with the /doc switch.
12. What debugging tools come with the .NET SDK?
.CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR.
13. What does assert() method do?
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.
14. What’s the difference between the Debug class and Trace class?
Use Debug class for debug builds, use Trace class for both debug and release builds.
15. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.
16. Where is the output of TextWriterTraceListener redirected?
To the Console or a text file depending on the parameter passed to the constructor.
17. How do you debug an ASP.NET Web application?
Attach the aspnet_wp.exe process to the DbgClr debugger.
18. What are three test cases you should go through in unit testing?
1. Positive test cases (correct data, correct output).
2. Negative test cases (broken or missing data, proper handling).
3. Exception test cases (exceptions are thrown and caught properly).
19. Can you change the value of a variable while debugging a C# application?
Yes. If you are debugging via Visual Studio.NET, just go to Immediate window.
20. 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. OLE-DB.NET is a .NET layer on top of the OLE layer, so it’s not as fastest and efficient as SqlServer.NET.
21. What is the wildcard character in SQL?
Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.
22. Explain ACID rule of thumb for transactions.
A transaction must be:1. Atomic - it is one unit of work and does not dependent on previous and following transactions.2. Consistent - data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t.3. Isolated - no transaction sees the intermediate results of the current transaction).4. Durable - the values persist if the data had been committed even if the system crashes right after.
23. Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted?
Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.
24. What are the ways to deploy an assembly?
An MSI installer, a CAB archive, and XCOPY command.
25. What namespaces are necessary to create a localized application?
System.Globalization and System.Resources.
26. What is the smallest unit of execution in .NET?
An Assembly.

No comments:

Post a Comment