Top 50 . Net Interview Questions
Q1. What Is The Difference Between Datareader And Dataadapter?
@Data Reader is study simplest forward simplest and lots faster than DataAdapter.
@If you operate DataReader you need to open and near connection explicitly where as if you use DataAdapter the connection is mechanically opened and closed.
@DataReader is connection orientated where as Data Adapter is disconnected
Q2. What Is Gc (rubbish Collection) And How It Works
One of the coolest capabilities of the CLR is Garbage Collection, which runs in the heritage accumulating unused item references, liberating us from having to make certain we usually ruin them. In reality the time distinction among you releasing the item instance and it being garbage amassed is probable to be very small, for the reason that GC is constantly walking.
[The process of tritively tracing through all pointers to actively used objects in order to locate all objects that can be referenced, and then arranging to reuse any heap memory that was not found during this trace. The common language runtime garbage collector also compacts the memory that is in use to reduce the working space needed for the heap.]
Heap:
A part of memory reserved for a application to use for the brief storage of facts structures whose existence or size can't be determined until this system is walking.
Q3. Why String Are Called Immutable Data Type ?
The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is shaped & the start address is changed . Thus retaining the Old string in Memory for Garbage Collector to be disposed.
Q4. .Net Debug & Trace Interview Questions With Answers
What is spoil mode? What are the options to step through code? Hint class. Define Listeners collection of Trace and Debug gadgets. Application or game you need to layout, code and supply some greater characteristic to your output. To do the above, you need some controls, IDE and so forth.
Silverlight Tool kit is nothing but is a collection of Silverlight Tools, Components and many others. It includes source code describing the all you want to expand an utility.
Q6. What Is Exception Handling?
When an exception takes place, the gadget searches for the nearest trap clause that may cope with the exception, as determined by using the run-time sort of the exception. First, the cutting-edge technique is looked for a lexically enclosing try statement, and the associated seize clauses of the attempt announcement are taken into consideration so as. If that fails, the technique that called the cutting-edge technique is searched for a lexically enclosing try declaration that encloses the point of the call to the modern approach. This search continues until a trap clause is discovered that could manage the modern-day exception, by naming an exception magnificence that is of the equal magnificence, or a base magnificence, of the run-time form of the exception being thrown. A capture clause that does not call an exception class can cope with any exception.
Once a matching catch clause is located, the machine prepares to trfer manipulate to the primary announcement of the capture clause. Before execution of the trap clause starts, the gadget first executes, in order, any subsequently clauses that were associated with attempt statements greater nested that than the one that caught the exception.
Exceptions that occur for the duration of destructor execution are worth special point out. If an exception occurs at some point of destructor execution, and that exception isn't caught, then the execution of that destructor is terminated and the destructor of the bottom elegance (if any) is known as. If there may be no base class (as in the case of the item kind) or if there's no base elegance destructor, then the exception is discarded.
Q7. Explain The Relationship Between Silverlight And Windows Media Technologies?
Silverlight is built on pinnacle of Windows Media permitting builders and architects to collaborate in constructing media studies and RIAs. Silverlight is launched by means of the Server and Tools Division at Microsoft as a part of the .NET Framework.
Q8. What Is Side-with the aid of-aspect Execution? Can Two Application One Using Private Assembly And Other Using Shared Assembly Be Stated As A Side-by-facet Executables?
Side-by-aspect execution is the capability to run a couple of versions of an utility or factor at the identical laptop. You may have more than one variations of the common language runtime, and multiple versions of applications and additives that use a model of the runtime, on the identical pc on the same time. Since versioning is best applied to shared assemblies, and not to personal assemblies, two utility one using non-public assembly and one using shared meeting cannot be said as facet-by-facet executables,
Q9. How Many Languages .Net Is Supporting Now?
When .NET was added it came with several languages.
VB.NET,
C#,
COBOL
and
Perl, and so on.
Q10. Advantages Of Vb.Internet And C#
Advantages VB.NET :-
* Has aid for non-obligatory parameters which makes COM interoperability a whole lot clean.
* With Option Strict off late binding is supported.Legacy VB functionalities may be used by using Microsoft.VisualBasic namespace.
* Has the WITH assemble which isn't always in C#.
* The VB.NET part of Visual Studio .NET compiles your code in the heritage.
While that is considered a bonus for small tasks, human beings creating very massive initiatives have found that the IDE slows down significantly as the challenge gets large.
Advantages of C#
* XML documentation is generated from source code but this is now been integrated in Whidbey.
*Operator overloading which is not in modern-day VB.NET however is been introduced in Whidbey.
* The the use of assertion, which makes unmanaged aid disposal simple.
* Access to Unsafe code. This allows pointer arithmetic and so forth, and can improve overall performance in some conditions. However, it is not for use lightly, as quite a few the normal safety of C# is misplaced (because the call implies).This is the predominant difference that you could access unmanaged code in C# and no longer in VB.NET
Q11. Why Doesn't The .Net Runtime Offer Deterministic Destruction?
Because of the garbage collection algorithm. The .NET garbage collector works by way of periodically walking via a list of all of the gadgets which can be currently being referenced by an utility. All the gadgets that it doesn't find throughout this seek are equipped to be destroyed and the memory reclaimed. The implication of this algorithm is that the runtime does not get notified at once when the final reference on an item goes away - it simplest finds out in the course of the following sweep of the heap.
Futhermore, this kind of algorithm works first-rate through appearing the rubbish collection sweep as hardly ever as possible. Normally heap exhaustion is the cause for a set sweep.
Q12. How Can Iis Improve Silverlight Streaming?
IIS smooth streaming enables for handing over HD streams easily on any tool. IIS smooth streaming is an extension of IIS7 Media Services 3.@It allows adaptive live streaming via HTTProtocols.
Q13. Is It Compulsory To Have Script Manager On The Page When You Are Using Any Control Of Ajax Control Tool Kit?
Yes. Page desires to have a script supervisor for ajax manipulate device kit controls to work.
Q14. What Is A Clr Host?
The Windows operating device does not provide support for running a CLR software. That support is supplied by a CLR host. A CLR host is an utility this is liable for loading the CLR right into a system, developing application domains in the manner, and executing user code inside the application domains. Examples of hosts that deliver with the .NET Framework consist of:
ASP.NET. An ISAPI clear out that ships with ASP.NET hundreds the CLR and does the initialization vital to deal with web requests.
Internet Explorer. A MIME clear out hooks into Internet Explorer versions 5.01 and better to execute controlled controls referenced from HTML pages.
Shell Executables. When a managed utility is released from a shell, a small piece of unmanaged code masses the CLR and tritions control of the utility to the CLR.
Q15. What Is The Difference Between An Exe And A Dll?
You can create an items of Dll but now not of the EXE.
Dll is an In-Process Component whereas EXE is an OUt-Process Component.
Exe is for single use while you could use Dll for multiple use.
Exe may be commenced as standalone wherein dll can't be.
Q16. Asp.Internet - How To Find Last Error Which Occurred?
Server.GetLastError();
[C#]
Exception LastError;
String ErrMessage;
LastError = Server.GetLastError();
if (LastError != null)
ErrMessage = LastError.Message;
else
ErrMessage = "No Errors";
Response.Write("Last Error = " + ErrMessage);
Q17. Explain The Mouse Events That Silverlight Currently Supports.
The mouse occasions that supports silverlight are
LostMouseCapture - happens whilst an UI element lost mouse seize
MouseMove - happens whilst the mouse function modifications
MouseEnter - happens when the mouse pointer enters into the bounding location of an item
MouseLeave - happens when the mouse pointer leaves the bounding vicinity of an object
MouseLeftButtonDown - takes place whilst the left mouse button is down
MouseLeftButtonU - occurs while the left mouse button is up observed through MouseLeftButtonDown
Q18. Observations Between Vb.Net And Vc#.Net?
Choosing a programming language depends on your language revel in and the scope of the utility you are constructing. While small programs are frequently created the use of best one language, it is not uncommon to develop large applications using multiple languages.For example, if you are extending an utility with current XML Web services, you may use a scripting language with very little programming effort. For consumer-server programs, you will probably choose the unmarried language you are most comfy with for the complete application. For new employer applications, wherein huge groups of builders create components and offerings for deployment throughout multiple far off web sites, the great desire is probably to use numerous languages relying on developer abilties and long-term protection expectations.The .NET Platform programming languages - inclusive of Visual Basic .NET, Visual C#, and Visual C++ with controlled extensions, and many other programming languages from various companies - use .NET Framework services and capabilities via a commonplace set of unified lessons. The .NET unified classes offer a steady method of gaining access to the platform's functionality. If you discover ways to use the magnificence library, you will locate that each one tasks observe the same uniform structure. You no longer need to analyze and master exclusive API architectures to jot down your packages.
Q19. What Is Clr
It is the runtime that converts a MSIL code into the host system language code, that's then accomplished as it should be. It is the execution engine for .NET Frameworkapplications. It presents a number of services, including:
Code management (loading and execution)
Application reminiscence isolation
Verification of type safety
Conversion of IL to local code.
Access to metadata (greater kind statistics)
Managing memory for controlled gadgets
Enforcement of code get right of entry to security
Exception dealing with, including move-language exceptions
Interoperation among managed code, COM items, and pre-current DLL's (unmanaged code and information)
Automation of item format
Support for developer services (profiling, debugging, and so forth.
Q20. How To Exclude A Property From Xml Serialization?
[XmlIgnore] (use characteristic on the belongings) Eg: [XmlIgnore] public string Name ..
Q21. How To Manage Pagination In A Page Using .Internet?
Using pagination option in DataGrid manage is to be had in .NET. We should set the quantity of statistics for a web page, then it takes care of pagination with the aid of itself routinely.
Q22. How Can I Create Image Pieces/sub Image?
In instantly manner you create a subimage from an present photograph. Here you just clip an photo, Clipping is simply exceptional from Cropping. In clipping, first you have to dictate which a part of the pics to attract and later you have to remove all but the desired a part of the image. Silverlight does now not support cropping.
Q23. What Is A Proxy In Web Service? How Do I Use A Proxy Server When Invoking A Web Service?
If you're the use of the SOAP Toolkit, you need to set a few connector properties to use a proxy server:
Dim cleaning soap As SoapClient Set cleaning soap=New SoapClient cleaning soap.ConnectorProperty("ProxyServer") = ?Proxyservername? Cleaning soap.ConnectorProperty("ProxyPort") = ?8080? Soap.ConnectorProperty("UseProxy") = True
While with .NET , you simply need to create a System.Net.WebProxy object and use it to set the Proxy assets Dim
webs As localhost.MyService() webs.Proxy=New System.Net.WebProxy(?Http://proxyserver:8080?)
Q24. I'm Having Some Trouble With Cas. How Can I Troubleshoot The Problem?
Caspol has more than one options that would help. First, you may ask caspol to tell you what code institution an assembly belongs to, the use of caspol -rsg. Similarly, you could ask what permissions are being carried out to a particular meeting the use of caspol -rsp
Q25. What's Thread.Sleep() In Threading ?
Thread's execution can be paused by means of calling the Thread.Sleep method. This approach takes an integer value that determines how long the thread must sleep. Example Thread.CurrentThread.Sleep(2000). It'll paused for 2 2d.
Q26. What Are The Contents Of Assembly?
A static meeting can encompass 4 elements:
Assembly show up-Contains the meeting metadata. An assembly occur consists of the facts approximately the identity and version of the assembly. It additionally carries the statistics required to clear up references to kinds and resources.
Type metadata-Binary facts that describes a program.
Microsoft intermediate language(MSIL)code.
A set of assets
Q27. Describe How To Perform Event Handling In Silver Light
Event coping with is executed in two event instances – Input events and Non-enter activities.
Q28. What Are Object Pooling And Connection Pooling And Difference? Where Do We Set The Min And Max Pool Size For Connection Pooling?
Object pooling is a COM+ service that allows you to reduce the overhead of making every object from scratch. When an item is activated, it is pulled from the pool. When the item is deactivated, it's miles located returned into the pool to look forward to the following request. You can configure object pooling by way of applying the ObjectPoolingAttribute attribute to a class that derives from the System.EnterpriseServices.ServicedComponent class.
Object pooling lets you manipulate the wide variety of connections you operate, rather than connection pooling, where you manipulate the maximum quantity reached. Following are essential variations between item pooling and connection pooling:
Creation. When the usage of connection pooling, introduction is at the equal thread, so if there is nothing inside the pool, a connection is created for your behalf. With object pooling, the pool might decide to create a new object. However, when you have already reached your most, it as an alternative gives you the subsequent available object. This is essential behavior whilst it takes a long term to create an object, however you do now not use it for extremely lengthy.
Enforcement of minimums and maximums. This isn't always completed in connection pooling. The most price in object pooling could be very crucial whilst looking to scale your utility. You may want to multiplex thousands of requests to just a few objects. (TPC/C benchmarks depend upon this.)
COM+ item pooling is same to what's used in .NET Framework controlled SQL Client connection pooling. For instance, creation is on a specific thread and minimums and maximums are enforced.
Q29. How Do I Run Managed Code In A Process?
The first step in going for walks managed code in a process is to get the CLR loaded and initialized the usage of a CLR host. Typically, a host consists of both controlled code and unmanaged code. The controlled code which executes within the default area is normally responsible for developing the software domains wherein the consumer code exists. All CLR hosts should incorporate unmanaged code due to the fact execution should begin in unmanaged code. The .NET Frameworks presents a fixed of unmanaged APIs that the host can use to configure the CLR, load the CLR right into a technique, load the hosts controlled code into the default domain, and trition from the unmanaged code to the managed code. The second step in running controlled code in a technique is to create software domain names in which the consumer code will execute. The creator of the software domain can specify criteria which manage code isolation, security, and loading of assemblies. The third step in jogging controlled code in a technique is to execute person code in one or more application domains created within the preceding step. All code this is run in the CLR ought to be part of an assembly. There are three options for loading assemblies. First, precompiled assemblies can be loaded from disk. Second, precompiled assemblies may be loaded from an array of bytes. Third, assemblies may be constructed dynamically in an software domain the use of the BCL Reflection Emit APIs.
Note. For an software launched from the command-line, the shell host executes the stairs defined above on behalf of the consumer and hides the complexity from the person.
Q30. What Is Garbage Collection In .Net? Garbage Collection Process?
The method of tritively tracing thru all hints to actively used gadgets so that it will find all gadgets that may be referenced, after which arranging to reuse any heap memory that became now not determined in the course of this hint. The commonplace language runtime garbage collector also compacts the reminiscence this is in use to reduce the operating space wanted for the heap.
Q31. Where Do You Add An Event Handler?
It's the Attributesproperty, the Add feature inner that assets. E.G.BtnSubmit.Attributes.Add("onMouseOver","someClientCode();")
Q32. What Is Custom Attribute? How To Create? If I'm Having Custom Attribute In An Assembly, How To Say That Name In The Code?
The primary steps to correctly design custom attribute training are as follows:
Applying the AttributeUsageAttribute
([AttributeUsage(AttributeTargets.All,
Inherited = false, AllowMultiple = true)])
Declaring the attribute. (class public magnificence MyAttribute : System.Attribute // .
. . )
Declaring constructors (public MyAttribute(bool myvalue) this.Myvalue =
myvalue; )
Declaring properties
public bool MyProperty
get return this.Myvalue;
set this.Myvalue = fee;
The following instance demonstrates the simple manner of the use of reflection to get get right of entry to to custom attributes.
Magnificence MainClass
public static void Main()
System.Reflection.MemberInfo data = typeof(MyClass);
item[] attributes = information.GetCustomAttributes();
for (int i = 0; i < attributes.Length; i ++)
System.Console.WriteLine(attributes[i]);
Q33. What Are Possible Implementations Of Distributed Applications In .Net?
.NET Remoting and ASP.NET Web Services. If we talk approximately the Framework Class Library, noteworthy instructions are in System.Runtime.Remoting and System.Web.Services.
Q34. What Is Difference Between Code Access And Role Based Security?
Code safety is the method of using permissions and permission units for a given code to run. The admin, for example, can disable running executables off the Internet or restriction get right of entry to to company database to most effective few packages.
Role security most of the time includes the code strolling with the privileges of the cutting-edge person. This way the code can't supposedly do more harm than mess up a single consumer account.
Neither is higher. It relies upon on the character of the application; each code-based and position-primarily based protection might be carried out to an extent.
Q35. What Is Difference Between Il And Dll ?
DLL contains the IL and other information (metadata) inner.
Q36. What Is Cls?
Common Language Specification (CLS) defines the policies and standards to which languages ought to adhere to in an effort to be well suited with different .NET languages. This permits C# developers to inherit from training described in VB.NET or other .NET well suited languages
Q37. What Is Finalize Method In .Internet?
Object.Finalize approach in .NET is commonly used to easy and launch unmanaged sources like OS documents, window and so on. Even even though Garbage collector in .NET has the capability to decide the lifestyles time of such gadgets, however, without a information the way to smooth them. The Finalize technique lets in an item to smooth up such unmanaged resources when the garbage collector desires to reclaim the reminiscence. However, Finalize technique need to be averted until necessary as it influences the overall performance because reclaiming the memory used by gadgets with Finalize strategies requires at the least rubbish collections.
Q38. Explain How To Apply Style Elements In A Silverlight Project?
Application resources utilize the style elements for assisting the paperwork. The App.Xaml report will be used to comprise an application resource XML assemble. Each fashion’s target kind is set to the control that wishes the style.
Q39. Will The Finally Block Get Executed If An Exception Has Not Occurred?
Yes.
Q40. Difference Between Type Constructor And Instance Constructor? What Is Static Constructor, When It Will Be Fired? And What Is Its Use?
(Class constructor method is also called type constructor or kind initializer) Instance constructor is carried out whilst a brand new example of type is created and the class constructor is achieved after the kind is loaded and earlier than any person of the sort members is accessed. (It gets executed only 1st time, whilst we call any static techniques/fields in the identical elegance.) Class constructors are used for static area initialization. Only one magnificence constructor according to kind is permitted, and it can not use the vararg (variable argument) calling convention.
A static constructor is used to initialize a category. It is referred to as mechanically to initialize the elegance earlier than the primary example is created or any static individuals are referenced.
Q41. What The Different Phase/steps Of Acquiring A Proxy Object In Webservice?
Following are the specific steps had to get a proxy object of a webservice at the consumer aspect:
-Client communicates to UDDI node for webservice both thru browser or UDDI’s public internet provider.
-UDDI node responds with a listing of webservices.
-Every carrier listed by means of webservice has a URI pointing to DISCO or WSDL report.
-After parsing the DISCO document, we follow the URI for the WSDL record associated with the webservice which we want.
-Client then parses the WSDL file and builds a proxy object which could speak with Webservice.
Q42. How Can We Call Methods In Remoting Asynchronously?
We can make Asynchronous technique calls by means of the usage of delegates.
Q43. How Can You To Add Javascript To A Page When Performing An Asynchronous Postback?
Use the ScriptManager elegance. This class incorporates numerous techniques like the RegisterStartupScript(), Register Client ScriptBlock(), Register Client Script Include(), Register Array Declaration(), Register Client Script Resource(), Register Expand oAttribute(), Register On SubmitStatement() which helps to feature javascript while appearing an asynchronous postback.
Q44. Steps For Creating Clr Trigger?
Follow those steps to create a CLR trigger of DML (after) kind to carry out an insert movement:
• Create a .NET magnificence of triggering action
• Make an assembly (.DLL) from that Class
• Enable CLR environment in that database.
• Register the meeting in SQL Server
• Create CLR Trigger the usage of that assembly
Q45. Can Source Code Be Reverse-engineered From Il?
Yes, it's miles regularly fantastically trustworthy to regenerate high-stage source from IL. Lutz Roeder'sReflector does a excellent activity of turning IL into C# or VB.NET.
Q46. What Is The Difference Between Viewstate And Sessionstate?
ViewState persist the values of controls of specific page within the patron (browser) when put up returned operation performed. When person requests every other web page previous page statistics now not available.
SessionState persist the statistics of specific user inside the server. This data available until person close the browser or session time completes.
ViewState Relate to Controls, it me when Client send request inside the shape of Controls' cost to server,In case any validation trouble referring to Clients information then the complete facts isn't cleaned because it turned into arise is asp,it could repair the existing data within the shape of hidden manage and render records through server to respective controls,as a result consumer will now not enter the whole data once more, in which as SessionState pertains to character consumer,it manages the consumer related information and hold the session between client server.
Q47. What Is Dcom?
DCOM is a disbursed extension of COM. It differs from COM in that it allows for creating gadgets distributed throughout a community, a protocol for invoking that item's techniques, and comfy to the item. DCOM gives a wrapper around COM, as a result it is a backward like minded extension.
Q48. Using Directive Vs Using Statement
You create an example in a using declaration to make sure that Dispose is called on the object while the the use of assertion is exited. A the use of announcement can be exited both whilst the quit of the the use of declaration is reached or if, as an instance, an exception is thrown and manipulate leaves the statement block earlier than the quit of the announcement.
The the use of directive has two uses:
Create an alias for a namespace (a the use of alias).
Permit the usage of types in a namespace, such that, you do now not ought to qualify the usage of a type in that namespace (a using directive).
Q49. What's Typical About A Windows Process In Regards To Memory Allocation?
Each manner is allotted its very own block of to be had RAM area, no manner can get entry to any other technique code or records. If the technique crashes, it dies on my own with out taking the complete OS or a gaggle of other packages down.
Q50. How To Create An Ajax Website Using Visual Studio?
Using Visual Studio Web Developer Express 2005 & variations above it, Ajax based totally applications may also effortlessly be created. Note that the Ajax Framework & Ajax Extensions should be hooked up (In case of VS 2005). If using Visual Studio 2008 Web Developer Express or above, Ajax comes along with it (so no want of a separate set up).

