Dotnet difference questions & answers Compiled-1

64
DOTNET Framework Difference FAQs-1.pdf HTML-XML Difference Faqs.pdf ASP.NET Difference FAQs.pdf Design Patterns Difference FAQs.pdf Dotnet Programming Concepts Difference FAQs.pdf LINQ Difference FAQs.pdf OOPs Difference FAQs.pdf Sql Server Difference FAQs.pdf WCF Difference FAQs.pdf ADO.NET Difference FAQs-1.pdf Comparative Chart of ASP.Net 2.0,3.0 and 3.5 Features.pdf Difference Between ASP.Net 2.0 and ASP.Net 3.5.pdf

description

This provides huge collection (120+) of DOTNET Technology FAQs which are of "Difference Between" type

Transcript of Dotnet difference questions & answers Compiled-1

Page 1: Dotnet difference questions & answers Compiled-1

DOTNET Framework Difference FAQs-1.pdf

HTML-XML Difference Faqs.pdf

ASP.NET Difference FAQs.pdf

Design Patterns Difference FAQs.pdf

Dotnet Programming Concepts Difference FAQs.pdf

LINQ Difference FAQs.pdf

OOPs Difference FAQs.pdf

Sql Server Difference FAQs.pdf

WCF Difference FAQs.pdf

ADO.NET Difference FAQs-1.pdf

Comparative Chart of ASP.Net 2.0,3.0 and 3.5 Features.pdf

Difference Between ASP.Net 2.0 and ASP.Net 3.5.pdf

Page 2: Dotnet difference questions & answers Compiled-1

1) What is the difference between CCW and RCW?

S.No CCW RCW1 COM to .NET communication

happens through COM Callable Wrapper

.NET to COM Communication happens through Runtime Callable Wrapper

2) What are the differences between Dll and Exe?

S.No Dll Exe1 Objects of Dlls can be created Objects of Exe cannot be created2 Dll is In-Process Exe is Out-Process3 It cannot be started as a standalone It can be started as a standalone

3) What are the differences between Managed Code and Unmanaged Code?

S.No Managed Code Unmanaged Code1 It is executed under CLR It is not executed under CLR2 It compiles to intermediate language It compiles directly to machine code3 It provides services like security,

exception handling, garbage collection etc

It does not provide security, exception handling, garbage collection etc

4 It can access both managed and unmanaged code

It can access only unmanaged code

Page 3: Dotnet difference questions & answers Compiled-1

1) What are differences between XML and HTML?

S.No XML HTML1 XML provides user definable tags HTML provides defined set of tags

designed for web display2 XML is content driven HTML is format driven3 End tags are essential in a well

formed XML document. In a well formed document, elements can be defined as single tag or a pair of tags like <student/> or the <student>…</student> pair

End tags are not always required.<HTML> tag needs an equivalent </HTML> tag but <br> tag does not require </br> tag

4 Quotes required around attribute values

Quotes are not required for the values of attributes

5 Slash required in empty tags Slash not required6 XML is used for describing data HTML is used for designing pages

Page 4: Dotnet difference questions & answers Compiled-1

ASP.NET Difference FAQs-1.pdf

ASP.NET Difference FAQs-2.pdf

Page 5: Dotnet difference questions & answers Compiled-1

1) What are the differences between Inline code and Code Behind Code?S.No Inline code Code Behind Code1 Its within .aspx file Its in a external class file2 Dynamically compiled Compiled prior to deployment and

linked with .aspx file

2) What are the differences between Global.asax and Web.Config?S.No global.asax web.config1 It is a class file It is an XML file2 There can be only one for an

applicationThere can be many if under different sub-folders

3 Can have Application and Session events

Cannot have Application and Session events

4 Need to be recompiled when changes are made

No need to compile when changes are made

3) What are the Differences between Server.Transfer and Response.Redirect?S.No Server.Transfer Response.Redirect1 The navigation happens on the

server-side ,so client history is not updated

The navigation happens on the client-side ,so client history is updated

2 Data can be persist across the pages using Context.Item collection

Context.Items loses the persistence

3 No Round-trips Makes a Round-trip4 Has Good encapsulation No

4) What is the difference between a custom control and a user control?S.No User Control Custom Control1 Is a file with the .ascx extension Is a file with the .dll extension2 Can be only used with the

applicationCan be used in any number of applications

3 Language dependent They are language independent, a controlcreated in c# can be used in vb.net

4 Cannot be added to Visual studio Toolbox

Can be added to Visual studio Toolbox

5 Inherits from Server controls and easy to create

We have to develop from scratch , so comparativelydifficult

6 Generally used for static content Used when dynamic content is required

5) What is the difference between Caching and Application?S.No Caching Application1 Cache have expire policy Application does not have expire

policy2 Cache does not require explicit

lockingApplication require explicit locking

3 Cache has the Property of timeout, Application variables exist as long as

Page 6: Dotnet difference questions & answers Compiled-1

which allows us to control the duration of the Objects so cached

the application is alive

4 Output can be cached in 4 ways, Page Output Caching Page Partial Caching DataSource Caching Data Caching

Application does not have options as like Cache object

5 It is accessible to page level to all the users

It is accessible to both page level and application level to all the users

6) What is the difference between web farm and web garden?S.No Web farm Web garden1 A web application running on

multiple servers is called a web farm

A web application running on a single server that has multiple CPUs is called a web garden

7) What is the difference between Application and Session Events?S.No Application Event Session Event1 Application events are used to

initialize objects and data that we do want to make available to all the current sessions of our web application

Session events are used to initialize data that we want to keep throughout individual sessions, but that we do not want to share between sessions

8) What is the difference between Session Cookies and Persistent Cookies?S.No Session Cookies Persistent Cookies1 Session Cookies do not have

expiration datePersistent Cookies have an expiration date. The expiration date indicates to the browser that it should write the cookie to the client’s hard drive

9) What are the differences between Server Controls and HTML Controls?S.No Server Controls HTML Controls1 Server Controls can trigger

control-specific events on the server

HTML Controls can trigger only page-level events on server (postback)

2 Data entered in a server control is maintained across requests. Server controls retain state

Data is not maintained in an HTML control. Data must be saved and restored using page-level scripts

3 The Microsoft .NET Framework provides a set of properties for each server control. Properties allows us to change the server control’s appearance and behavior within server-side code

HTML controls have HTML attributes only

4 Server controls automatically detect browser and adapt display as appropriate

We must detect browser in code or write for least common denominator

10) What are the differences between ViewState and Hidden fields?S.No ViewState Hidden fields1 This is used for pages that will

postback to itselfThis is used for pages that will postback to itself or to another page

Page 7: Dotnet difference questions & answers Compiled-1

2 This is built in structure for maintaining state of a page

This is not an inbuilt structure

3 Security is more as data is hashed, compressed and encoded

Security is less when compared to ViewState

11) What is the difference between SQL Cache Notification and SQL Cache Invalidation?S.No SQL Cache Notification SQL Cache Invalidation1 Using SQL Cache Notification,

we can generate notifications when the data of a database on which a cached item depends changes

Using SQL Cache Invalidation, we can make a cached item invalid that depends on the data stored in a SQL server database, when the data in the SQL server database is changed

12) What is the difference between absolute time expiration and sliding time expiration?S.No Absolute time expiration Sliding time expiration1 In absolute time expiration, a

cached item expires after the expiration time specifies for it, irrespective of how often it is accessed

In sliding time expiration, the time for which the item is cached is each time incremented by its expiration time if it is accessed before completion of its expiration time

13) What is the difference between adding items into cache through Add() method and Insert() method?S.No Cache.Add() Cache.Insert()1 Cache.Add() method also returns

an object representing the item we have added in the cache ,besides adding the item in the cache

Cache.Insert() method adds only the item in the cache

2 It is not possible to replace an existing item in the cache using the Cache.Add() method

We can replace an existing item in the cache using the Cache.Insert() method

14) What is the difference between page-level caching and fragment caching?S.No Page-level caching Fragment caching1 In Page-level caching, we cache

a whole pageIn Fragment caching, we cache parts of the web page such as a user control added to the web page

15) What is the difference between Label control and Literal control?S.No Label control Literal control1 Final HTML code of a Label

control has an HTML tagFinal HTML code of a Literal control contains only text, which is not surrounded by any HTML tag

16) What is the difference between HyperLink control and LinkButton control?S.No HyperLink control LinkButton control1 A HyperLink control do not have

Click and Command eventsA LinkButton control have Click and Command events, which can be handled in the code behind file of the web page

Page 8: Dotnet difference questions & answers Compiled-1

17) What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control?S.No HtmlInputCheckBox control HtmlInputRadioButton control1 We can select more than one

HtmlInputCheckBox control from a group of HtmlInputCheckBox controls

We can select only a single HtmlInputRadioButton control from a group of HtmlInputRadioButton controls

18) How a content page differs from a master page?

S.No Content page Master page1 A content page does not have

complete HTML source codeA master page has complete HTML source code inside its source file

19) How will you differentiate a submaster page from a top-level master page?S.No Submaster page Top-level master page1 Like a content page, a submaster

page also does not have complete HTML source code

Top-level master page has complete HTML source code inside its source file

20) What is the difference between a page theme control and a global theme?S.No Page theme Global theme1 A page theme is stored inside a

subfolder of the App_Themes folder of a web application

A global theme is stored inside the Themes folder on a web server

2 It can be applied to individual web pages of the web application

It can be applied to all the web sites on the web server

21) What is the difference between a default skin and a named skin?S.No Default skin Named skin1 A default skin does not have a

SkinId attributeA named skin has a SkinId attribute

2 It is automatically applied to all the controls of the same type present on a web page

It is applied to a control explicitly by setting the SkinId property of the control from the Properties window

22) Differentiate Globalization and LocalizationS.No Globalization Localization1 Globalization is the process of

identifying the specific portion of a web application that needs to be different for different languages and isolating that portion from the core of the web application

Localization is the process of configuring a web application to be supported for a specific language or locale

23) What are the differences between web.config and machine.config?S.No web.config machine.config1 This is automatically created

when we create an ASP.Net web application project

This is automatically installed when we install Visual Studio. Net

2 This is also called application level configuration file

This is also called machine level configuration file

Page 9: Dotnet difference questions & answers Compiled-1

3 We can have more than one web.config file

Only one machine.config file exists on a server

4 This file inherits setting from the machine.config

This file is at the highest level in the configuration hierarchy

Page 10: Dotnet difference questions & answers Compiled-1

Difference between Web site and Web application

S.No Web site Web application

1 Can mix vb and c# page in single website.

We can't include c# and vb page in single web application.

2 Can not establish dependencies. We can set up dependencies between multiple projects.

3 Edit individual files after deployment.

Can not edit individual files after deployment without recompiling.

4 Right choice when one developer will responsible for creating and managing entire website.

Right choice for enterprise environments where multiple developers work unitedly for creating,testing and deployment.

i.e.,In web site development, decoupling is not possible.

i.e.,In Web application, different different groups work on various components independently like one group work on domain layer, other work on UI layer.

5 Web site is easier to create than Web application

Web application is more difficult to create than a Web site

Difference between Local storage and cookies

S.No Local storage Cookies

1 Good to store large amount of data, up to 4MB

Good for small amount of data, up to 4KB

2 Easy to work with the JavaScript Difficult to work with JavaScript 3 Local storage data is not sent to the

server on every request (HTTP header) as it is purely at the client side

All data is transferred to and from server, so bandwidth is consumed on every request

4 No way to specify the time out period as the Cookies have

Can specify timeout period so that cookies data are removed from browser

Difference between Session and Cache

S.No Session Cache

1 Ssession retains state per user Cache is used for retaining state for application scoped items.

2 Items put into a session will stay there, until the session ends

Items in the cache can expire (will be removed from cache) after a specified amount of time. And also there is no guaranty that objects will not be removed before their expiration times as ASP.NET remove items from cache when the amount of available memory gets small. This process is called as Scavenging.

3 The session state can be kept external (state server, SQL server) and shared between several instances of our web app (for load balancing).

This is not the case with the cache.

Page 11: Dotnet difference questions & answers Compiled-1

Difference between Datalist and Repeater

S.No Datalist Repeater

1 Datalist supports multiple columns displaying and using repeat columns property

Repeater doesn't support multiple columns display,no repeat columns property

2 Datalist supports styles for formating templates data[headerstyle,...]

Repeater does not provide styles

3 Datalist rendering output[html content]will be slow compare with repeater.

Repeater performanace is better than Datalist

Summary:

If the requirement can achieve using repeater and datalist,choose repeater for better performance

Page 12: Dotnet difference questions & answers Compiled-1

1. Difference between Factory Pattern and Abstract Factory Pattern

S.No Factory Pattern Abstract Factory Pattern

1 Create object through inheritance Create object through composition

2 Produce only one product Produce families of products

3 Implements code in the abstract creator that make use of the concrete type that sub class produces

Concrete factories implements factory method to create product

2.Difference between Abstract Factory Pattern And Builder Pattern

S.No Builder Pattern Abstract Factory Pattern

1 In Builder Pattern, there will be one Director class which will instruct Builder class to build the different parts/properties of our object and finally retrieve the object.

Abstract Factory Pattern will return the instance directly.

2 It will have reference to the created object.

It does not keep the track of it's created object.

3.Difference between Builder Pattern And Composite Pattern

S.No Builder Pattern Composite Pattern

1 It is used to create group of objects of predefined types.

It creates Parent - Child relations between our objects.

4.Difference between MVC and MVP

S.No MVP MVC

1 MVP is a bit more complex to implement than MVC .Also, it has additional layer for view interfaces.

MVC is easier to implement than MVP.

2 The request is always received by the View and delegated to the presenter which in turn gets the data does the processing

The request is received by the controller which in turn gets the required data and loads up the appropriate view

3 The presentation and view logic an be unit tested as the view is loosely coupled.

The controller logic can be unit tested. Note: We can unit test view if we are using Razor view engine. ASPX viewengine are not that easily unit testable

4 MVP is best suitable for Windows Programming as the flow naturally tend towards this pattern.

MVC is best suitable for Web Programming.

Page 13: Dotnet difference questions & answers Compiled-1

5.Difference between Proxy Pattern and Observer Pattern

S.No Proxy Pattern Observer Pattern

1 The Proxy Pattern is used for wrapping a kind of special object with 1 or more other objects.

The Observer Pattern is used by a publisher object to notify subscriber objects with information.

2 Either because we don't always have the wrapped object or because it needs to be managed in a certain way that can be simplified via the proxy object(s). This is kind of a way to exchange the API of an existing class with a proxy class. We are not just talking events here, but whatever kind of functionality to define via the proxy object instead of the real object.

The publisher object does not know the subscribing objects - except that the conform to a certain subscriber interface. This is a very flexible pattern for distributing events, since those that wants to listen on certain object has the power to do so without changing the code of the publishing object.

6. Difference between Singleton Pattern and a static class

S.No Singleton Pattern static class

1 Singleton pattern maintains single instance.

We cannot create instance for static class.

2 A singleton can extend classes and implement interfaces.

A static class cannot .Note: It can extend classes, but it does not inherit their instance members.

3 A singleton can be initialized lazily or asynchronously.

A static class is generally initialized when it is first loaded, leading to potential class loader issues.

4 Singletons can be handled polymorphically without forcing their users to assume that there is only one instance.

static class cannot be handled polymorphically.

5 Singleton Class can have value when Class object instantiated between server and client, such a way if three client want to have a shared data between them Singleton can be used.Thats why singleton class can be used for state mangement in stateless scenarios like shopping cart scenario.

Static are always just shared and have no instance but multiple references.

6 We can pass singleton object as parameter

We cannot pass parameter in static class

7 Singleton provides flexibility and also provides sort of a mechanism to control object creation based on various requirements. They can be extended as well if need arises. In other words we are not always tied to a particular implementation. With Singleton we

Static classes once defined could not accomodate any future design changes as by design static classes are rigid and cannot be extended.

Page 14: Dotnet difference questions & answers Compiled-1

have the flexibility to make changes as when situation demands.

7.Difference between Strategy and Inversion of Control (IOC)

S.No Strategy Pattern Inversion of Control (IOC) Pattern

1 The strategy pattern is useful when we want classes to depend on the interface rather than the implementation.And we can easily swap out behavior depending on which concrete implementation we provide.

Inversion of Control/Dependency Injection (IoC/DI) comes into play when we want the concrete strategy implementation injected into a class. For example, we could use the DI Framework Ninject and configure it so that it will know which concrete strategy implementation to inject into a class in specific scenarios.

Note: Strategy is just one of the ways that IOC is implemented

8.DIfference between IDictionary and Dictionary

S.No IDictionary Dictionary

1 IDictionary is just a contract, abstraction Dictionary is concrete implementation.

2 It is recommended for example to expect as argument an IDictionary rather than concrete Dictionary, or to expose property of IDictionary rather than Dictionary, because this promotes loose coupling. Than we are able to change underlying objects in the future without affecting those who use your object.

Argument or Property is not required for Dictionary.

9.Difference between Factory Pattern and Dependency Injection

S.No Factory Pattern Dependency Injection(DI)

1 Factory is used to create objects DI is used to move the responsibility of creating an object outside the main code.

2 Some of the well known framework available for DI are

1. Unity Application Block (Microsoft)2. Ninject3. StructureMap4. Castle Windsor5. Munq/Funq6. Autofac

Page 15: Dotnet difference questions & answers Compiled-1

10.Difference between String.Clone() and String.Copy() method

S.No String.Clone() String.Copy()

1 Returns a reference to this instance of String.

i.e., it gives pointer value(ie Current memory Reference)

Creates a new instance of String with the same value as a specified String.

i.e., it creates an instance in Heap Memory and gives pointer value(ie New Memory Reference)

11.Difference between Strategy Pattern and Factory Pattern

S.No Strategy Pattern Factory Pattern

1 Strategy's sole intent to is to provide a mechanism to select different algorithm.

Factory's sole purpose is to create objects .

2 We cannot use "strategy" to create objects of "factory".

We can use "factory" to create objects of "strategy".

12.Difference between Proxy and Adaptor

S.No Proxy Pattern Adaptor Pattern

1 Proxy on the other hand represents a standin object for the real object. This is required when the real object is complex to create, is not available, or for authentication purpose. For e.g. web service proxy, proxy authentication server etc.

Proxy can be categorized into

Virtual Proxy Remote Proxy Protection Proxy

Adapter is used to adapt to incompatible interfaces. It's more directed from the client (those who consume the object) perspective. A client expects an interface to be of particular type and adapter plays a role in filling that gap.

It's more from making it easier for the client to adapt to other third party libraries within there own by adapting to it.

13.Difference between Decorator and Visitor

S.No Decorator Pattern Visitor Pattern

1 Decorator may have just a single object to customize.

Visitor has a tree of objects to be worked upon.

2 Decorator does not require a traverser for successful implementation.

Visitor requires a traverser for successful implementation.

3 Decorator pattern is a structural pattern that help us to add new function to an object in the run time , note that in the run time not design time .

Visitor pattern is Behavioral pattern that seperate the data structure from the operation (functionality ) that work on it , this mean we can add different operation on the same data structure

Page 16: Dotnet difference questions & answers Compiled-1
Page 17: Dotnet difference questions & answers Compiled-1

Dotnet Programming Concepts Difference FAQs-1.pdf

Dotnet Programming Concepts Difference FAQs-2.pdf

Page 18: Dotnet difference questions & answers Compiled-1

Difference between hash table and arraylist

S.No Arraylist Hash table

1 Array List is a List Hash Table is a map

2 Here, we can only add items to the list Here, we can add data with the key

3 Retrieving data using Arraylist is slower than Hashtable because If we want to find something in a arraylist we have to go through each value in arraylist.

Retrieving by key in Hashtable is faster than retrieving in Arraylist because If we want to find something in a hashtable we dont have to go through each value in hashtable, instead search for key values and is faster.

Difference between Hash Table and Arrays

Hash Table Array

Hash table stores data as name,value pair. Array stores only value

To access value from hash table, we need to pass name.

In array, to access value , we need to pass index number.

We can store different type of data in hash table, say int,string etc.

In array ,we can store only similartype of data.

Difference between Dictionary and Hashtable

Dictionary Hashtable

Dictionary is a generic type Hashtable is not generic type.

In Dictionary we need to specify the types of both the key and the corresponding value.The value represents the actual object stored and the key represents a means to identify a particular object.

Hashtable is a collection of name/value pairs that are organised on the basis of hash code of the key being specified.

In Dictionary public static members are type safe but any instance members are not type safe.

Hashtable is thread safe for use by multiple reader threads and a single writing thread.

We cannot use Dictionary with Web Services The reason is no web service standard supports generic standard.

We can use Hashtable withWeb Services

Dictionary is aster than Hashtable because boxing is not required.

It is slower than dictionary because to retrieve a value we must cast it as its actual type, because it will be returned via object reference.

Page 19: Dotnet difference questions & answers Compiled-1

Difference between array and stack

Array Stack

An array can be multi-dimensional Stack is strictly one-dimensional

An array allows direct access to any of its elements

With a stack, only the 'top' element is directly accessible; to access other elements of a stack, we must go through them in order, until we get to the one we want

Difference between Stack and Heap

Stack Heap

Memory will be allocated at the compile time. Memory will be allocated at the run time.

Here the memory is allocated by the compiler. Here the memory is allocated by the user.

Memory will be allocated only in sequential locations.

Memory will be allocated in sequential locations and non- sequential locations.

The memory will also be deleted by the compiler.

The memory must be deleted explicitly by the user.

There is lot of chance of memory wastage. There is no chance of memory wastage if the memory is handled perfectly.

Difference between Array and ArrayList

Array ArrayList

They are fixed length. They are resizable and variable length

They are compiled strong type collection. They are flexible and can accommodate any data types.

Because arrays are of fixed size and strong type collection performance is faster.

In arraylist lots of boxing and unboxing are done there for its performance is slower.

Array is in the System namespace ArrayList is in the System.Collectionsnamespace.

Ex:Char[] vowel=new Char[]; Ex:ArrayList a_list=new ArrayList();

Page 20: Dotnet difference questions & answers Compiled-1

1.Difference between for and foreach loop

S.No For loop Foreach loop

1 In case of for the variable of the loop is always be int only.

In case of Foreach the variable of the loop while be same as the type of values under the array.

2 The For loop executes the statement or block of statements repeatedly until specified expression evaluates to false.

The Foreach statement repeats a group of embedded statements for each element in an array or an object collection.

3 There is need to specify the loop bounds(Minimum, Maximum).

We do not need to specify the loop bounds minimum or maximum.

4 example: using sytem; class class1 { static void Main() { int j=0; for(int i=0; i<=10;i++) { j=j+1; } Console.ReadLine(); } }

example: using sytem; class class1 { static void Main() { int j=0; int[] arr=new int[] {0,3,5,2,55,34,643,42,23}; foreach(int i in arr) { j=j+1; } Console.ReadLine(); } }

2. Difference between Covariance and Contravariance

S.No Covariance Contravariance

1 Converting from a broader type to a specific type is called co-variance.If B is derived from A and B relates to A, then we can assign A to B. Like A=B. This is Covariance.

Converting from a more specific type to a broader type is called contra-variance. If B is derived from A and B relates to A, then we can assign B to A. Like B= A. This is Contravariance.

2 Co-variance is guaranteed to work without any loss of information during conversion. So, most languages also provide facility for implicit conversion.

e.g. Assuming dog and cat inherits from animal, when you convert from animal type to dog or cat, it is called co-variance.

Contra-variance on the other hand is not guaranteed to work without loss of data. As such an explicit cast is required.

e.g. Converting from cat or dog to animal is called contra-variance, because not all features (properties/methods) of cat or dog is present in animal.

3 Example:

Page 21: Dotnet difference questions & answers Compiled-1

class Fruit { }

class Mango : Fruit { }

class Program

{

delegate T Func<out T>();

delegate void Action<in T>(T a);

static void Main(string[] args)

{

// Covariance

Func<Mango> mango = () => new Mango();

Func<Fruit> fruit = mango;

// Contravariance

Action<Fruit> fr = (frt) =>

{ Console.WriteLine(frt); };

Action<Mango> man = fr;

}

}

4 Note:

1. Co-variance and contra-variance is possible only with reference types; value types are invariant.

2. In .NET 4.0, the support for co-variance and contra-variance has been extended to generic types. No now we can apply co-variance and contra-variance to Lists etc. (e.g. IEnumerable etc.) that implement a common interface. This was not possible with .NET versions 3.5 and earlier.

Page 22: Dotnet difference questions & answers Compiled-1

3.Difference between IList and IEnumerable

S.No IList IEnumerable

1 IList is used to access an element in a specific position/index in a list.

IEnumerable is a forward only collection, it can not move backward and between the items.

2 IList is useful when we want to Add or remove items from the list.

IEnumerable does not support add or remove items from the list.

3 IList can find out the no of elements in the collection without iterating the collection.

Using IEnumerable we can find out the no of elements in the collection after iterating the collection.

4 IList does not support filtering. IEnumerable supports filtering.

4.Difference between IEnumerable and IQueryable

S.No IEnumerable IQueryable

1 IEnumerable exists in System.Collections Namespace.

IQueryable exists in System.Linq Namespace.

2 IEnumerable is best to query data from in-memory collections like List, Array etc.

IQueryable is best to query data from out-memory (like remote database, service) collections.

3 While query data from database, IEnumerable execute select query on server side, load data in-memory on client side and then filter data.

While query data from database, IEnumerable execute select query on server side with all filters.

4 IEnumerable is suitable for LINQ to Object and LINQ to XML queries.

IQueryable is suitable for LINQ to SQL queries.

5 IEnumerable does not supports custom query.

IQueryable supports custom query using CreateQuery and Execute methods.

6 IEnumerable does not support lazy loading. Hence not suitable for paging like scenarios.

IQueryable support lazy loading. Hence it is suitable for paging like scenarios.

7 Extension methods supports by IEnumerable takes functional objects.

Extension methods supports by IEnumerable takes expression objects means expression tree.

8 IEnumerable Example

MyDataContext dc = new MyDataContext (); IEnumerable list = dc.loyees.Where(p => p.Name.StartsWith("S")); list = list.Take(10);

Generated SQL statements of above query will be :

SELECT [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0] WHERE [t0].[EmpName] LIKE @p0

Page 23: Dotnet difference questions & answers Compiled-1

Note: In this query "top 10" is missing since IEnumerable filters records on client side

IQueryable Example

MyDataContext dc = new MyDataContext (); IEnumerable list = dc.loyees.Where(p => p.Name.StartsWith("S")); list = list.Take(10);

Generated SQL statements of above query will be :

SELECT TOP 10 [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0] WHERE [t0].[EmpName] LIKE @p0

Note: In this query "top 10" is exist since IQueryable executes query in SQL server with all filters.

5.Difference between IEnumerable and IEnumerator

S.No IEnumerable IEnumerator

1 The IEnumerable interface is a generic interface that provides an abstraction for looping over elements. In addition to providing foreach support, it allows us to tap into the useful extension methods in the System.Linq namespace, opening up a lot of advanced functionality The IEnumerable interface contains an abstract member function called GetEnumerator() and return an interface IEnumerator on any success call.

IEnumerator provides two abstract methods and a property to pull a particular element in a collection. And they are Reset(), MoveNext() and Current The signature of IEnumerator members is as follows: void Reset() : Sets the enumerator to its initial position, which is before the first element in the collection. bool MoveNext() : Advances the enumerator to the next element of the collection. object Current : Gets the current element in the collection

2 IEnumerable does not remember the cursor state i.e currently row which is iterating through

IEnumerator does remember the cursor state

3 IEnumerable is useful when we have only iterate the value

IEnumerator is useful when we have to pass the iterator as parameter and has to remember the value

Page 24: Dotnet difference questions & answers Compiled-1

LINQ Difference FAQs-1.pdf

LINQ Difference FAQs-2.pdf

Page 25: Dotnet difference questions & answers Compiled-1

1.Difference between LINQ and SQL

S.No LINQ SQL

1 LINQ Stands for language integrated query.

SQL stands for Structured Query Language.

2 LINQ Statements are verified during compile time.

SQL statements can be used in a application gets verified for their syntaxes only in the run time.

3 To use LINQ we can depend upon our .Net Language syntaxes and also we can consume base class library functionalities.

To use SQL we need to be familiar with SQL syntaxes and also the pre-defined functions of SQL like MAX,MIN,LEN and SUBSTRING etc...

4 LINQ Statements can be debugged as they execute under framework environment. SQL .

As SQL statements execute on Database server debugging of the code is not possible.

2.Difference between LINQ to SQL and Entity Framework

S.No LINQ to SQL Entity Framework

1 It only works with Sql server. It works with variety of db products.

2 Used for rapid application development.

Cannot used for rapid application development.

3 It does not support for complex type.

It provides support for complex type.

4 It cannot generate db from model. It can generate db from model.

5 Mapping type ( class to single table)

Mapping type ( class to multiple tables)

6 We can query data using DataContext.

We can query data using esql,object services,entity client and linq to entities.

Another Good Reference:

http://jinaldesai.net/linq-to-sql-vs-entity-framework/

(OR)

http://www.slideshare.net/jinaldesailive/linq-to-sql-vs-entity-framework-jinal-desai

Page 26: Dotnet difference questions & answers Compiled-1

3.Difference between LINQ and Stored Procedures

S.No LINQ Stored Procedures

1 As LINQ is part of .NET, we can use visual studio’s debugger to debug the queries

It is really very hard to debug the Stored Procedure

2 With LINQ everything gets complied into single DLL hence deployment becomes easy.

With Stored Procedures, we need to provide an additional script for deployment

3 LINQ is type safe, so queries errors are type checked at compile time.It is really good to encounter an error when compiling rather than runtime exception!

Stored Procedures are not type safe i.e., error can be caught only during runtime.

4 LINQ supports multiple databases With Stored Procedures which need to be re-written for different databases.

5 LINQ supports abstraction which allows framework to add additional improvements like multi threading. It is much simpler and easier to add this support through LINQ than Stored Procedures.

As Stored Procedures does not support abstaction , so it is difficult to add additional impovements like multi threading

6 LINQ queries need to compile before execution.Therefore, LINQ is slower than Stored Procedures.

Stored Procedures are ster thn LINQ because they are precompiled i.e., Stored Procedures have a predictable execution plan.Therefore, if a stored procedure is being executed for the second time, the database gets the cached execution plan to execute the stored procedure.

4.Difference between LINQ to SQL and LINQ to Objects

S.No LINQ to SQL LINQ to Objects

1 LINQ to SQL needs a Data Context object. The Data Context object is the bridge between LINQ and the database.

LINQ to Objects does not need any intermediate LINQ provider or API.

2 LINQ to SQL returns data of type IQueryable<T>

LINQ to Objects returns data of type IEnumerable<T>.

Page 27: Dotnet difference questions & answers Compiled-1

3 LINQ to SQL is translated to SQL by way of Expression Trees, which allow them to be evaluated as a single unit and translated to the appropriate and optimal SQL statements.

LINQ to Objects does not need to be translated.

4 LINQ to SQL is translated to SQL calls and executed on the specified database

LINQ to Objects is executed in the local machine memory.

5.Difference between LINQ to SQL and LINQ to Entities

S.No LINQ to SQL LINQ to Entities

1 Does not support Conceptual Data Model

Supports Conceptual Data Model

2 Does not support Storage Schema Supports Storage Schema

3 Does not support Mapping Schema Supports Mapping Schema

4 Does not support New Data Access Provider

Supports New Data Access Provider

5 Does not support Non-SQL Server Database Support

Supports Non-SQL Server Database Support

6 Supports Direct Database Connection

Does not support Direct Database Connection

7 Does not support Multiple-table Inheritance

Supports Multiple-table Inheritance

8 Does not support Single Entity from Multiple Tables

Supports Single Entity from Multiple Tables

Page 28: Dotnet difference questions & answers Compiled-1

1.Difference between LINQ to SQL and ADO.NET

S.No LINQ to SQL ADO.NET

1 Used for data handling with SQL Server databases only.

Used for data handling with any database: SQL Server/Access/Oracle/Excel etc.

2 Uses the extension methods of System.Linq.Queryable class.

Does not use the extension methods of System.Linq.Queryable class.

3 Introduced in .net Framework 3.0 It is there since the .net Framework 1.0

4 DataContext is used for Database connectivity.

SqlConnection/OleDbConnection are used for database connectivity

5 Syntax and coding is somewhat complex.

Easier syntax and coding.

Note: Both LINQ TO SQL and ADO.NET have connected / disconnected modes of datahandling

2.Difference between LINQ and nHibernate

S.No LINQ nHibernate

1 LINQ is not an open-source nHibernate is an open source.

2 LINQ is an incomplete ORM tool as it needs additional extensions.

nHibernate is an ORM tool

3 LINQ is primarily a querying language

nHibernate has a limited querying language.

4 LINQ is much more useful in small applications where there is no massive dependence on databases.

nHibernate is much more useful in largel applications where there is massive dependence on databases.

5 With LINQ, database already exists and the relationships and some programming will be dependent on how the database is defined.

With nHibernate, database does not already exist and it needs to be defined .

Page 29: Dotnet difference questions & answers Compiled-1

3.Difference between LINQ and Entity Framework

S.No LINQ Entity Framework

1 Used for Rapid Application Development

Used for Enterprise Development

2 Works with objects in database Works with Conceptual model of database

3 Mainly woks with SQL Server Works with all data sources

4 ".dbml" is created while using LINQ to SQL

".EDMX" is created while using Entity Framework

Page 30: Dotnet difference questions & answers Compiled-1

OOPs Difference FAQs-1.pdf

OOPs Difference FAQs-2.pdf

OOPs Difference FAQs-3.pdf

Page 31: Dotnet difference questions & answers Compiled-1

1) What are the differences between TypeOf() and GetType()?S.No TypeOf() GetType()1 Its an operator Its a method2 Can't be overloaded Has lot of overloads

2) What are the differences between const and readonly?S.No const readonly1 It cannot be static It can be instance level or static2 It is evaluated at design time It is evaluated at run time3 It is initialized at declaration It is initialized at declaration or in

constructor4 It must be of integral type or

enumerationIn addition, it can have complex types with new keyword and enumerations are not allowed

3) What are the Differences between Abstract Class and Interface?S.No Abstract Class Interface1 It can have implemented Methods It cannot have implemented Methods2 A class can inherit only one abstract

classA Class can implement any number of Interfaces

3 We go for Abstract classes on such situations where we need to give common functionality for group of related classes

We go for Interface on such situations where we need to give common functionality for group of un-related classes

4 If we add a new method, then we can provide a default implementation and so no need to make any change to existing work

If we add a new method, then we need to change all the existing work

5 Static and Instance constants are possible

Only Static constants are possible

4) What are the differences between Structure and Class?S.No Structure Class1 It is value type It is reference type2 It is stored on stack It is stored on heap3 It does not support inheritance It supports inheritance4 It is suitable for small data structure It is suitable for complex data structures

5) What are the differences between property and indexer?S.No Property Indexer1 A property can be static member An indexer is always an instant member2 The get accessor of a property

corresponds to a method with no parameters

The get accessor of an indexer corresponds to the same formal parameter lists as the indexer

6) What are the differences between overloading and overriding?S.No Overloading Overriding1 Same name in same / derived class

but with different / type of parameterWe need to provide different implementation than base class

2 Has different signature Has same signature3 Otherwise called Compile-time Otherwise called Run-time Polymorphism

Page 32: Dotnet difference questions & answers Compiled-1

Polymorphism

7) What are the differences between Value Types and Reference Types?S.No Value Types Reference Types1 It is stored on stack It is stored on heap2 It can be accessed directly It can be accessed through references3 Life time of value type is determined

by lifetime of variable that contain them

Lifetime of reference type is managed by .net framework

4 Examples: All numeric data type, Boolean, char, Date, Structure, enumerations

Examples: All arrays, String, Class types, Delegate

Note: Object is not any kind of type. You can create object of structure as well as Class

Are not type: Namespaces, Modules, Events, properties, procedures, variables, constants, & fields.

Page 33: Dotnet difference questions & answers Compiled-1

Difference between Events and Delegates

S.No Events Delegates

1 Event can be used in an interface definition

Delegate cannot be used in an interface definition

2 Event can only be invoked from the class that declares it

Delegates can be invoked from child classes and clients.

3 Event comes with its pair of accessors i.e Add and Remove. An event is always assigned and unassigned with a += and -= operator.

There is no pair of accessors concept in delegates.

4 Event has a restrictive signature and must always be of the form Event (object source, EventArgs args)

Delegates do not have restrictive

signature as like events

Difference between Class and Object

S.No Class Object

1 It is a datatype that contains the programming logic.

It is a chunk of memory that implements the class logic.

2 Class is visible in the source code and resides in hard disk.

Object is in the RAM and not visible in source code.

3 Class is like a template or blueprint of the object. It implements reusability,encapsulation, inheritance

It is the real world implementation of the class. Each object has its own copy of data.

4 Example:Button is a class with properties like Text,BackColor, events like click, methods like Focus

Example: Button1, Button2 are the objects of Button class.

5 We can create subclasses We cannot create sub-objects

Difference between Private and Static ConstructorS.No Static constructor Private constructor

1 A static constructor is called before the first instance is created. i.e. global initializer.

Private constructor is called after the instance of the class is created.

2 Static constructor will be called first time when the class is referenced.Static constructor is used to initialize static members of the class.

Static members will not be initialized either by private or public constructor.

3 The static constructor will only be executed once.

The private constructor will be executed each time it is called.

Page 34: Dotnet difference questions & answers Compiled-1

Difference between properties and methods

S.No Properties Methods

1 Properties are used to represent data

Methods are used to performs actions

2 Properties are created by using getter and setter i.e., get{} and set{}

Methods create like public void method1(parameter list here)

Difference between Singleton Pattern and a static class

S.No Singleton Pattern static class

Singleton pattern maintains single instance.

We cannot create instance for static class.

2 A singleton can extend classes and implement interfaces.

A static class cannot .Note: It can extend classes, but it does not inherit their instance members.

3 A singleton can be initialized lazily or asynchronously.

A static class is generally initialized when it is first loaded, leading to potential class loader issues.

4 Singletons can be handled polymorphically without forcing their users to assume that there is only one instance.

static class cannot be handled polymorphically.

5 Singleton Class can have value when Class object instantiated between server and client, such a way if three client want to have a shared data between them Singleton can be used.Thats why singleton class can be used for state mangement in stateless scenarios like shopping cart scenario.

Static are always just shared and have no instance but multiple references.

6 We can pass singleton object as parameter

We cannot pass parameter in static class

7 Singleton provides flexibility and also provides sort of a mechanism to control object creation based on various requirements. They can be extended as well if need arises. In other words we are not always tied to a particular implementation. With Singleton we have the flexibility to make changes as when situation demands.

Static classes once defined could not accomodate any future design changes as by design static classes are rigid and cannot be extended.

Page 35: Dotnet difference questions & answers Compiled-1
Page 36: Dotnet difference questions & answers Compiled-1

Difference between Abstraction and Encapsulation

Abstraction Encapsulation

Abstraction solves the problem in the design level.

Encapsulation solves the problem in the implementation level.

Abstraction is used for hiding the unwanted data and giving relevant data.

Encapsulation means hiding the code and data into a single unit to protect the data from outside world.

Abstraction allows us to focus on what the object does instead of how it does it

Encapsulation means hiding the internal details or mechanism of how an object does something.

Abstraction- Outer layout, used in terms of design.For Example:- Outer Look of a Mobile Phone, like it has a display screen and keypad buttons to dial a number.

Encapsulation- Inner layout, used in terms of implementation.For Example:- Inner Implementation detail of a Mobile Phone, how keypad button and Display Screen are connected with each other using circuits

Difference between Composition and Aggregation

Composition Aggregation

Defines a strong-coupled relationship between two entities, where the one entity is part of another, and both need each other for their existence.

Defines a weak-coupled relationship between two entities, where one entity could be part of another, but either can exist without the other, independantly.

e.g. Human body and the Heart. e.g.School and teacher.

Composition implies real ownership of its components

Aggregation does not necessarily own any of its aggregates.

Composition has a stronger bond of its components.

Aggregation has weaker or looser bonds with its aggregates.

Composition has components that exist at the inner level.

Aggregation has aggregates that live at the outer level.

Page 37: Dotnet difference questions & answers Compiled-1

Difference between Private Class and Sealed Class

Private Class Sealed Class

A Private class can only be accessed by the class it is defined and contain within - it is completely inaccessible to outside classes.

A Sealed class can be accessed by any class.Private Constructor of a Private Class = Sealed Class.

In private Class,we can create a constructor and therefore we can create an instance of that class.

In Sealed class we can not create a constructor of that class, so no instance of that class is possible.

public class A { private class B { } B b = new B(); }public class C { A.B b = new A.B(); // ERROR }

public sealed class A { }public class B : A //ERROR { }

The main use of Private class is to create a user-defined type, which we want to be accessible to that class only.

Private class(i.e private constructor) is also used to implement singleton classes(pattern). Singleton means "A single-instance object, and it simplify complex code. Singletons have a static property that we must access to get the object reference."

The sealed classes are mainly used to prevent inheritance features of object oriented programming.

Difference between Static Class and Sealed Class

Static Class Sealed Class

We can neither create their instances, nor inherit them

We can create their instances, but cannot inherit them

They can have static members only. They can contain static as well as nonstatic members.

ex: static class Program

ex:

Page 38: Dotnet difference questions & answers Compiled-1

{

}

sealed class demo {

}

class abc:demo { --Wrong }

Static classes are used when a class provides functionality that is not specific to any unique instance.

The sealed classes are mainly used to prevent inheritance features of object oriented programming.

Difference between Virtual method and Abstract method

Feature Virtual method Abstract method

Overriding Virtual method may or may not override by inherited class.

i.e.,Virtual method provide the derived class with the option of overriding it. Virtual = = Overridable

An abstract method should be overriden by inherited class.

i.e.,Abstract method forces the derived class to override it.

abstract == MustOverride

Implementation Virtual method has an implementation.

Abstract method does not provide an implementation.

Necessity to Implement

Virtual methods allow subclasses to provide their own implementation of that method using the override keyword

Abstract methods in a class contain no method body, and are implicitly virtual

Scope Virtual methods scope to members only.

Abstract method's scope to members and classes

Instancing Virtual methods - Not applicable, as we can't create instance for members, it is possible only with classes.

Abstract method - direcly NO, but other way, Yes. We can create an instance of a class that derives from an abstract class. And we can declare a type Abstract class and instantiate that as a derived class.

Page 39: Dotnet difference questions & answers Compiled-1

Example:

public abstract class Test{

public abstract void A(); // Abstract method

public virtual void B() { Console.WriteLine("Test.B"); } // Virtual Method }

public class InheritedTest : Test {

public override void A() { Console.WriteLine("InheritedTest.A"); }

//Method B implementation is optional

public override void B() { Console.WriteLine("InheritedTest.B"); } }

Difference between Class and Static Class

Class Static Class

Class has Instance Members Static class does not have Instance Members

In Class, Constructor has Access Specifier.

In Static Class, Constructor does not have Access Specifier.

In Class Constructor, initiation is done every time when an object is created for the class

In Static Class ,Constructor will be called only one time .

In Class, Class members can be accessed through class object.

In Static Class, members can be accessed through its Class name only

Page 40: Dotnet difference questions & answers Compiled-1

Difference between Method Overloading and Method overriding in C#

Method Overloading Method overriding

Method Overloading is passing same message for different functionality

Method Overriding is redifining parent class function to the child class

Method Overloading is between the same function name with the different signature

Method Overriding is between the same method.

Method Overloading does not check for the return type.

Method Overriding checks the return type.

Method Overloading takes place in the same class.

Method Overriding takes place between parent and child classes

Method Overloading is static binding Method Overriding is a dynamic binding.

Page 41: Dotnet difference questions & answers Compiled-1

SQL Server Difference FAQs-1.pdf

SQL Server Difference FAQs-2.pdf

SQL Server Difference FAQs-3.pdf

SQL Server Difference FAQs-4.pdf

SQL Server Difference FAQs-5.pdf

Page 42: Dotnet difference questions & answers Compiled-1

1) What are the Differences between TRUNCATE and Delete?S.No Truncate Delete1 Truncate is faster Delete is comparatively slower2 Removes all rows from a table Can remove specific rows with Where

clause3 Is DDL Command Is DML Command4 Resets identity of the table Does not reset identity of the table5 Removes the data by deallocating

the data pages and logs the deallocation.

Removes one row at a time and records an entry in the transaction log for each deleted row.

6 Cannot be rolled back Can be rolled back

2) What are the differences between Primary key and Unique key?S.No Primary Key Unique Key1 Creates Clustered index Creates Non-Clustered index2 Null values are not allowed Allows only one null value

3) What are the Differences between Clustered Indexes and Non-Clustered Indexes?

S.No Clustered Indexes Non-Clustered Indexes1 It reorders the physical storage of

records in the tableIt sorts and maintain a separate storage

2 There can be only one Clustered index per table

More than one

3 The leaf nodes contain data The leaf node contains pointer to data

4) What are the differences between Stored Procedures and User Defined Functions?S.No Stored Procedures User Defined Functions1 Stored Procedure cannot be used

in a Select statementUser Defined Function can be used in a Select statement

2 Stored procedure supports Deferred Name Resolution

User Defined Function does not support Deferred Name Resolution

3 Stored Procedures are generally used for performing Business Logic

User Defined Functions are generally used for Computations

4 Stored Procedure need not return a value

User Defined Functions should return a value

5 Stored Procedures can return any datatype

User Defined Functions cannot return Image

6 Stored Procedures can accept more number of input parameters than User Defined Functions. Stored Procedures can have upto 21000 input parameters

User Defined Functions accept lesser number of input parameters than Stored Procedures. UDF can have upto 1023 input parameters

7 Stored Procedures can use Temporary Tables

Temporary Tables cannot be used in a User Defined Function

8 Stored Procedures can execute Dynamic SQL

User Defined Functions cannot execute Dynamic SQL

9 Stored Procedure supports error handling

User Defined Function does not support error handling. RAISEERROR or @@ERROR are

Page 43: Dotnet difference questions & answers Compiled-1

not allowed in UDFs10 Non-deterministic functions can

be used in Stored Procedures.Non-deterministic functions cannot be used in User Defined Functions (UDFs). For example, GETDATE() cannot be used in User Defined Functions(UDFs)

5) What are the differences between Where and Having clauses?S.No Where clause Having clause1 It applies to individual rows It applies to a group as a whole2 It selects rows before grouping It selects rows after grouping3 It cannot contain aggregate

functionsIt can contain aggregate functions

4 It can be used in select, delete ,insert etc.

It is used only in select clause

6) What are the differences between Union and UnionAll?S.No Union UnionAll1 This is used to eliminate duplicate

rowsIt will not eliminate duplicate rows

2 This selects only distinct rows It selects all the values3 It can be used to combine any

number of queriesIt can be used to combine maximum of 2 queries

4 It cannot contain aggregate functions

It can contain aggregate functions

7) What is the difference between normal Select statement and a Cursor?S.No Select statement Cursor1 Select statements are used for

table-level processingCursors are used for row-level processing

Page 44: Dotnet difference questions & answers Compiled-1

1) What are the differences between Instead of Triggers and After Triggers?S.No Instead of Triggers After Triggers1 Each table or view can have one

INSTEAD OF trigger for each triggering action (UPDATE, DELETE, and INSERT)

A table can have several AFTER triggers for each triggering action.

2 INSTEAD OF triggers fire in place of the triggering action and before constraints are processed.

AFTER triggers fire after the triggering action (INSERT, UPDATE, or DELETE) and after any constraints are processed.

2) What are the differences between Views and User-Defined Functions?S.No Views User-Defined Functions1 Views cannot accept parameters. User-Defined Functions can accept

parameters.2 Output of the Views cannot be

directly used in the SELECT clause.

Output of the User-Defined Functions can be directly used in the SELECT clause.

3) What are the differences between Triggers and Stored Procedures?S.No Triggers Stored Procedures1 Triggers cannot return a value Stored Procedures may return a value2 We cannot pass parameters in

TriggersWe can pass parameter in Stored Procedures

3 We can write a Stored procedure within a Trigger

We cannot write a Trigger within a Stored Procedure

4 Triggers are implicitly fired whenever insert, update or delete operations take place on table

Stored Procedures need to be explicitly called by the programmer

5 Triggers can only be implemented on Tables or Views

Stored procedures can be written for the Database

Page 45: Dotnet difference questions & answers Compiled-1

1.Difference between Identity and Sequence in SQL Server 2012

S.No Identity Sequence

1 Dependant on table. Independent from table.

2 Identity is a property in a table.

Example :

CREATE TABLE Tabletest_Identity

(

[ID] int Identity (1,1),

[Product Name] varchar(50)

)

Sequence is an object.

Example :

CREATE SEQUENCE [dbo].[Sequence_ID]

AS [int]

START WITH 1

INCREMENT BY 1

MINVALUE 1

MAXVALUE 1000

NO CYCLE

NO CACHE

3 If we need a new ID from an identity column we need toinsert and then get new ID.

Example :

Insert into [test_Identity] Values (‘SQL Server’)

GO

SELECT @@IDENTITY AS ‘Identity’

–OR

Select SCOPE_IDENTITY() AS ‘Identity’

In the sequence, we do not need to insert new ID, we can view the new ID directly.

Example :

SELECT NEXT VALUEFOR dbo.[Sequence_ID]

4 We cannot perform a cycle in identity column. Meaning, we cannot restart the counter after aparticular interval.

In the sequence, we can simply add one property to make it a cycle.

Example :

ALTER SEQUENCE [dbo].[Sequence_ID]

Page 46: Dotnet difference questions & answers Compiled-1

CYCLE;

5 We cannot cache Identity column property.

Sequence can be easily cached by just setting cache property ofsequence. It also improves the performance.

Example :

ALTER SEQUENCE [dbo].[Sequence_ID]

CACHE 3;

6 We cannot remove the identity column from the table directly.

The sequence is not table dependent so we can easily remove it

Example :

Create table dbo.[test_Sequence]

(

[ID] int,

[Product Name] varchar(50)

)

GO

–First Insert With Sequence object

INSERT INTO dbo.test_Sequence ([ID],[Product Name]) VALUES (NEXT VALUE FOR [Ticket] , ‘MICROSOFT SQL SERVER 2008′)

GO

–Second Insert without Sequence

INSERT INTO dbo.test_Sequence ([ID],[Product Name]) VALUES (2 , ‘MICROSOFT SQL SERVER 2012′)

7 We cannot define the maximum value in identity column it isbased on the data type limit.

Here we can set up its maximum value.

Example :

Page 47: Dotnet difference questions & answers Compiled-1

ALTER SEQUENCE [dbo].[Sequence_ID]

MAXVALUE 2000;

8 We can reseed it but cannot change the step size.

Example :

DBCC CHECKIDENT (test_Identity, RESEED, 4)

We can reseed as well as change the step size.

Example :

ALTER SEQUENCE [dbo].[Sequence_ID]

RESTART WITH 7

INCREMENT BY 2;

9 We cannot generate range from identity.

We can generate a range of sequencevalues from a sequence object with the help of sp_sequence_get_range.

2.Difference between Temp table and Table variable

S.No Temp table Table variable

1 A Temp table is easy to create and back up data.

But the table variable involves the effort when we usually create the normal tables.

2 Temp table result can be used by multiple users.

But the table variable can be used by the current user only.

3 Temp table will be stored in the tempdb. It will make network traffic. When we have large data in the temp table then it has to work across the database. A Performance issue will exist.

But a table variable will store in the physical memory for some of the data, then later when the size increases it will be moved to the tempdb.

4 Temp table can do all the DDL operations. It allows creating the indexes, dropping, altering, etc..,

Whereas table variable won't allow doing the DDL operations. But the table variable allows us to create the clustered index only.

5 Temp table can be used for the current session or global. So that a multiple user session can utilize the results in the table.

But the table variable can be used up to that program. (Stored procedure)

6 Temp variable cannot use the But we cannot do it for table variable.

Page 48: Dotnet difference questions & answers Compiled-1

transactions. When we do the DML operations with the temp table then it can be rollback or commit the transactions.

7 Functions cannot use the temp variable. More over we cannot do the DML operation in the functions .

But the function allows us to use the table variable. But using the table variable we can do that.

8 The stored procedure will do the recompilation (can't use same execution plan) when we use the temp variable for every sub sequent calls.

Whereas the table variable won't do like that.

Another Good Reference:

http://sqljunkieshare.com/2011/11/05/difference-between-temporary-tables-and-table-variables/

3.Difference between RAISERROR and THROW statements

S.No RAISERROR Statement THROW Statement

1 If a msg_id is passed to RAISERROR, the ID must be defined in sys.messages.

The error_number parameter does not have to be defined in sys.messages.

2 The msg_str parameter can contain printf formatting styles.

The message parameter does not accept printf style formatting.

3 The severity parameter specifies the severity of the exception.

There is no severity parameter. The exception severity is always set to 16.

4.Difference between Local temporary table and Global temporary table

S.No Local temporary table Global temporary table

1 Denoted by # symbol. Denoted by ## symbol.

2 Valid for the current connection only. They are cleared as soon as the current connection closes.

Available to all the connections once created. They are deleted when all users referencing the table disconnect from SQL Server .

3 Cannot be shared between multiple users.

Can be shared between multiple users.

Page 49: Dotnet difference questions & answers Compiled-1

1.Difference between Correlated subquery and Nested subquery

S.No Correlated subquery Nested subquery

1 Correlated subquery runs once for each row selected by the outer query. It contains a reference to a value from the row selected by the outer query.

Nested subquery runs only once for the entire nesting (outer) query. It does not contain any reference to the outer query row.

2 Correlated subquery follows down to top approach i.e., main query is executed first(even though parenthesis are present) and then child query.

We can also say: in a Correlated subquery,Inner query condition is used in the outer query

Nested subquery follows top-down approach i.e., child query is executed first and then parent .

We can also say:In a subqueryOuter query condition is used in the the inner query.

4 Example:

select e1.empname, e1.basicsal, e1.deptno from emp e1

where e1.basicsal = (select max(basicsal) from emp e2 where e2.deptno = e1.deptno)

Example:

select empname, basicsal, deptno from emp

where (deptno, basicsal) in (select deptno, max(basicsal) from emp group by deptno)

2.Difference between Weak Entity Set and Strong Entity Set

S.No Weak Entity Set Strong Entity Set

1 An entity set which does not possess sufficient attributes to form a primary key is known as a weak entity set.

An entity set which does have a primary key is called a strong entity set.

2 Member of a weak entity set is a subordinate entity.

Member of a strong entity set is a dominant entity.

3 Example:

Specific Person,Company,Event,Plant

Example:

Set of all Persons,Companies,Trees,Holidays

Page 50: Dotnet difference questions & answers Compiled-1

3.Difference between char and varchar data types in Sql Server

S.No Char Varchar

1 Fixed length memory storage Variable length memory storage(Changeable)

2 CHAR takes up 1 byte per character

VARCHAR takes up 1 byte per character, + 2 bytes to hold length information

3 Use Char when the data entries in a column are expected to be the same size like phone number

Use Varchar when the data entries in a column are expected to vary considerably in size like address

4 Ex: Declare test Char(100); test="Test" - Then "test" occupies 100 bytes first four bytes with values and rest with blank data

Ex: Declare test VarChar(100); test="Test" - Then "test" occupies only 4+2=6 bytes. first four bytes for value and other two bytes for variable length information.

4.Difference between Sql Server 2005 and Sql Server 2008

S.No Sql Server 2005 Sql Server 2008

1 XML datatype is introduced. XML datatype is used.

2 Cannot encrypt the entire database.

Can encrypt the entire database introduced in 2008.

3 Datetime is used for both date and time.

Date and time are seperately used for date and time

4 No table datatype is included. Table datatype introduced.

5 SSIS is started using. SSIS avails in this version.

6 CMS is not available. Central Management Server(CMS) is Introduced.

7 PBM is not available Policy based management(PBM) server is Introduced.

Page 51: Dotnet difference questions & answers Compiled-1

1.Difference between Database Mail and SQL Mail

S.No Database Mail SQL Mail

1 Based on SMTP (Simple Mail Transfer Protocol).

Based on MAPI (Messaging Application Programming Interface).

2 Introduced in Sql Server 2005. Used prior versions of Sql Server 2005.

3 No need to install Outlook. Require Outlook to be installed.

4 More secure than Sql mail. Less secure than Database mail.

2.Difference between Azure Table storage and SQL Azure

S.No Azure Table storage SQL Azure

1 It is built on top of the Azure Storage platform.

It is an SQL Server that has been configured to be hosted on top of the Windows Azure in a high availability mode.

2 It comprises flexible or schema-less entities. No referential integrity between the tables, and no custom indexes.

It comprises standard SQL Tables with indexes and referential integrity.

3 It can scale massive amounts of data due to the partition key.

It may not scale as far as Azure Table storage.

4 Can be thought as single spreadsheet.

Look familiar to any .Net developer who has used Sql server 2008 prior.

3.Difference between DBMS and RDBMS

S.No DBMS RDBMS

1 Stands for DataBase Management System

Stands for Relational DataBase Management System

2 In dbms no relationship concept It is used to establish the relationship concept between two database objects, i.e, tables

3 It supports Single User only It supports multiple users

4 It treats Data as Files internally It treats data as Tables internally

5 It supports 3 rules of E.F.CODD out off 12 rules

It supports minimum 6 rules of E.F.CODD

6 It requires low Software and It requires High software and

Page 52: Dotnet difference questions & answers Compiled-1

Hardware Requirements. hardware requirements.

7 DBMS is used for simpler business applications

RDBMS is used for more complex applications.

8 DBMS does not impose any constraints or security with regard to data manipulation

RDBMS defines the integrity constraint for the purpose of holding ACID PROPERTY

9 In DBMS Normalization process will not be present

In RDBMS, normalization process will be present to check the database table consistency

10 There is no enforcement to use foreign key concept compulsorily in DBMS

Although the foreign key concept is supported by both DBMS and RDBMS but its only RDBMS that enforces the rules

11 FoxPro, IMS are Examples SQL Server, Oracle are examples

4.Difference between SQL Server 2000 and SQL Server 2005

S.No SQL Server 2000 SQL Server 2005

1 Query Analyser and Enterprise manager are separate.

Both are combined as SSMS(Sql Server management Studio).

2 No XML datatype is used. .XML datatype is introduced.

3 We can create maximum of 65,535 databases.

We can create 2(pow(20))-1 databases.

4 Exception Handling mechanism is not available

Exception Handling mechanism is available

5 There is no Varchar(Max) data type is not available

Varchar(Max) data type is introduced.

6 DDL Triggers is not available DDL Triggers is introduced

7 DataBase Mirroring facility is not available

DataBase Mirroring facility is introduced

8 RowNumber function for paging is not available

RowNumber function for paging is introduced

9 Table fragmentation facility is not available

Table fragmentation facility is introduced

10 Full Text Search facility is not available

Full Text Search facility is introduced

Page 53: Dotnet difference questions & answers Compiled-1

11 Bulk Copy Update facility is not available

Bulk Copy Update facility is introduced

12 Data Encryption concept is not introduced

.Cannot encrypt the entire database

13 Cannot compress the tables and indexes.

Can Compress tables and indexes.(Introduced in 2005 SP2)

14 No varchar(max) or varbinary(max) is available.

Varchar(max) and varbinary(max) is used.

15 Data Transformation Services(DTS) is used as ETL tool

SQL Server Integration Services(SSIS) is started using from this SQL Server version and which is used as ETL tool

Page 54: Dotnet difference questions & answers Compiled-1

WCF Difference FAQs-1.pdf

WCF Difference FAQs-2.pdf

Page 55: Dotnet difference questions & answers Compiled-1

Difference between basicHttpBinding and wsHttpBinding

Criteria BasicHttpBinding WsHttpBinding

Security support

This supports the old ASMXstyle, i.e. WS-BasicProfile 1.1.

This exposes web services using WS-*specifications.

Compatibility This is aimed for clients who donot have .NET 3.0 installed and itsupports wider ranges of clients.Many of the clients like Windows2000 still do not run .NET 3.0. Soolder version of .NET canconsume this service.

As its built using WS-* specifications, itdoes not support wider ranges of clientand it cannot be consumed by older.NET version less than 3 version.

Soap version SOAP 1.1 SOAP 1.2 and WS-Addressingspecification.

Reliablemessaging

Not supported. In other words, ifa client fires two or three callsyou really do not know if theywill return back in the sameorder.

Supported as it supports WS-*specifications.

Default securityoptions

By default, there is no securityprovided for messages when theclient calls happen. In otherwords, data is sent as plain text.

As WsHttBinding supports WS-*, it hasWS-Security enabled by default. So thedata is not sent in plain text.

Security options

NoneWindows – default authenticationBasicCertificate

NoneTransportMessageTransport with message credentials

Difference between Message and Transport level security in WCF

Criteria Transport Security Message Security

Scenarios when we should be using one of them

When there are no intermediate systems in between this is the best methodology.

If it’s an intranet type of solution this is most recommended methodology.

When there are intermediate systems like one more WCF service through which message is routed then message security is the way to go.

Advantages Does not need any extra coding as protocol inherent security is used.

Performance is better as we can use hardware accelerators to enhance performance.

There is lot of interoperability support and communicating

Provides end to end security as it’s not dependent on protocol. Any intermediate hop in network does not affect the application.

Supports wide set of security options as it is not dependent on protocol. We can also implement custom security.

Page 56: Dotnet difference questions & answers Compiled-1

clients do not need to understand WS security as it’s built in the protocol itself.

Disadvantages As it’s a protocol implemented security so it works only point to point.

As security is dependent on protocol it has limited security support and is bounded to the protocol security limitations.

Needs application refactoring to implement security.

As every message is encrypted and signed there are performance issues.

Does not support interoperability with old ASMX webservices

Difference between Buffered transfer and Streamed transfer in WCF

S.No Buffered Transfer Streamed Transfer1 Target can process the message once

it is completely received.Target can start processing the data when it is partially received.

2 Performance will be good when message size is small

Performance will be good when message size is larger(more than 64K)

3 Native channel shape is IDuplexSessionChannel

Native channels are IRequestChannel and IReplyChannel

Difference between WCF and Web Services

S.No Features WebService WCF1 Hosting It can be hosted in IIS t can be hosted in IIS,

windows activation service, Self-hosting, Windows service

2 Programming [WebService] attribute has to be added to the class

[ServiceContract] attribute has to be added to the class

3 Model [WebMethod] attribute represents the method exposed to client

[OperationContract] attribute represents the method exposed to client

4 Operation One-way, Request- Response are the different operations supported in web service

One-Way, Request-Response, Duplex are different type of operations supported in WCF

5 XML System.Xml.serialization name space is used for serialization

System.Runtime.Serialization namespace is used for serialization

6 Encoding XML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, Custom

XML 1.0, MTOM, Binary, Custom

Page 57: Dotnet difference questions & answers Compiled-1

7 Transports Can be accessed through HTTP, TCP, Custom

Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom

8 Protocols Security Security, Reliable messaging, Transactions

9 State Management

Web Services are stateless WCF Services can manage states

Page 58: Dotnet difference questions & answers Compiled-1

Difference between Self Hosting and IIS Hosting

Feature Self Hosting IIS Hosting

Coding Effort We need to add some extra code to host the process

No need to add extra code Automatic hosting

Deployment Easy to deploy More difficult to deploy than Self-Hosting

Recycling Automatic process recycling is not possible

Automatic process recycling is possible

Service Lifetime Can control the service lifetime using Open and Close methods

Lifetime cannot be controlled manually.

Host Process Host process should be running before client makes a call to the service.

IIS host runs automatically when a client makes a call to the service.

Difference between Behaviour and Contract (OR)

Difference between Service Behaviour and Service Contract

Feature ServiceContract ServiceBehavior

Behaviour Affects the behavior of both client and server

Only affects the behavior of the server

Applicability Can apply to both interface and class

Only applicable to a class implementation

Impact on WSDL Affects the WSDL emitted Does not affect the WSDL

Difference between proxy and channel factory

Proxy Channel Factory

Only requires URL where the service resides We must have direct access to the assembly that contains that service contract T for

Very simpler Not easier

Easy to understand Channels are complex, network-related

There is Visual Studio gives us add the reference When we share a common service contract dll between the client and the server, we will be using the ChannelFactory class

Proxies have several restrictions like:1. Properties need to have gets and sets 2. Contructors cannot be exposed 3. Methods other than the service contract

cannot be exposed

If we know that our entities will not change much and the client code is less, then a DLL would work better than a proxy

By using SVCutil.exe we will create Proxy When we are using DLL that refers Service contract interface then use the channel factory class

Page 59: Dotnet difference questions & answers Compiled-1

Difference between DataContractSerializer and XMLSerializer

DataContractSerializer XMLSerializer

A practical benefit of the design of the DataContractSerializer is better performance over Xmlserializer. This is because DataContratSerializer explicitly shows the which fields or properties are serialized into XML.

XMLSerializer does not provide better performance when compare with DataContratSerializer because XMLSerializer does not indicate which fields or properties of the type are serialized into XML

The DataContractSerializer can translate the HashTable into XML.

XMLSerializer cannot translate the HashTable into XML.

DataContractSerializer is basically for very small, simple subset of the XML infoset.

XMLSerializer is used for complex schemas.

DataContractSerializer serializes private members.

XmlSerializer cannot serialize private members

DataContractSerializer uses the opts-in approach i.e, selecting the members that needs to be serialized .This is called as opts-in approach.

XmlSerializer uses opts-out approach i.e., marking the members do not need to be serialized. This is called as opts-out approach.

DataContractSerializer can serialize both private and public types.

XmlSerializer can serialize only public types. If we are trying to serialize a class that is marked private by InvalidOperation Exception will be thrown by the serializer.

DataContractSerializer does not need any default constructor before serializing any type.

For any types that needs to be serialized by XmlSerializer must have a default constructor.

DataContractSerializer does not give more control over the generated xml structure compared to the XmlSerializer.

XmlSerializer gives more control over the generated xml structure compared to the DataContractSerializer. For ex, if a field should come as an attribute or element.

DataContractSerializer can able to serialize types that implements Idictionary.

XmlSerializer cannot able to serialize types that implements IDictionary, for ex. Dictionary type cannot be serialized.

We can serialize a type that marked with [Serializable] attribute with DataContractSerializer. It serializes all the members (private, public) even they are marked with [XmlIgnore].

Only the public members are serialized not the private members. Suppose we do not need any of the member to be serialized we can use [XmlIgnore] attribute

WCF uses DataContractSerializer attribute Webservice uses XMLSerializer attribute

Page 60: Dotnet difference questions & answers Compiled-1

1) What are the differences between DataReader and DataAdapter?

S.No DataReader DataAdapter1 Works in Connected Mode Works in Disconnected Mode2 Can have only one record at a time Can have more than 1 records3 Is ForwardOnly and Readonly Can navigate front and back and editable4 Faster Slower

2) What are the differences between DataSet and DataReader?

S.No DataSet DataReader1 Works in Disconnected Mode Works in Connected Mode2 Can navigate back and forth Can navigate forward only3 Data is editable Data is Readonly4 Can contain more than one table

and relationshipsCan contain only one row at a time

5 Slower as having more overhead Faster when compared with DataSet

3) What is the difference between DataSet.Copy() and DataSet.Clone()?

S.No DataSet.Copy() DataSet.Clone()1 DataSet.Copy() copies both the

structure and dataDataSet.Clone() copies the structure of the DataSet, including all DataTable schemas, relations, and constraints and it does not copy any data

4) What are the differences between RecordSet and DataSet?

S.No RecordSet DataSet1 RecordSet provides data of one row

at an instantDataSet is a data structure which represents the complete table data at the same time

2 RecordSet always needs an Open connection to read the data from data sources

DataSet needs connection only for retrieving the data. After retrieve the data connection is not necessary

3 RecordSet is able to load the structure and data of only one table at a time

DataSet has the capability to store the structure and data of multiple tables at a time

4 RecordSet does not support constraints of Databases

DataSet enforces data integrity by using Constraints

5) What are the differences between ADO and ADO.Net?

S.No ADO ADO.Net

Page 61: Dotnet difference questions & answers Compiled-1

1 It supports connected model It supports disconnected model2 It uses record set It uses data set3 XML support is less XML support is more

Page 62: Dotnet difference questions & answers Compiled-1

New features of ASP.Net 2.0, ASP.Net 3.0 and ASP.Net 3.5- A Comparative Chart

SNo ASP.Net 2.0 ASP.Net 3.0 ASP.Net 3.51 a) Generics

b) Anonymous methods

c) Partial classd) Nullable typee) The new API gives

a fine grain control on the behavior of the runtime with regards to multithreading, memory allocation, assembly loading and more

f) Full 64-bit support for both the x64 and the IA64 hardware platforms

g) New personalization features for ASP.NET, such as support for themes, skins and webparts.

h) .NET Micro Framework

a) Windows Communication Foundation (WCF), formerly called Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services.

b) Windows Presentation Foundation (WPF), formerly called Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies.

c) Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows.

d) Windows CardSpace, formerly called InfoCard; a software component which securely stores a person's digital identities and

a) Linq for SQL, XML, Dataset, Object

b) Addin systemc) p2p base classd) Active directorye) ASP.NET Ajaxf) Anonymous types with

static type inferenceg) Paging support for

ADO.NETh) ADO.NET synchronization

API to synchronize local caches and server side datastores.

i) Asynchronous network I/O API

j) Support for HTTP pipelining and syndication feeds.

k) New System.CodeDom namespace.

Page 63: Dotnet difference questions & answers Compiled-1

provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website

Page 64: Dotnet difference questions & answers Compiled-1

Difference between ASP.Net 2.0 and ASP.Net 3.5

SNo

Feature ASP.Net 2.0 ASP.Net 3.5

1 New Features

ASP.Net 2.0 includes the following as new features,

a) Master Pagesb) Profilesc) GridView Control

ASP.Net 3.5 includes the following as new features,

a) ListView Controlb) DataPager Controlc) Nested Master Pagesd) LinqDataSource Control

2 Multi-targeting

ASP.Net 2.0 does not support Multi-Targeting environment.

ASP.Net 3.5 supports multi-targeting. It means that we choose from a drop-down list whether to have Visual Studio 2008 build applications against the ASP.NET 2.0, 3.0, or 3.5 frameworks.

3 AJAX Support

There is no in-built support for AJAX in ASP.Net 2.0. Instead, it has to be downloaded and installed.

In ASP.Net 3.5, AJAX is integrated into the .NET Framework, thereby making the process of building intuitive cool user interfaces easier.

4 Siverlight Support

It does not support Siverlight.

It supports Siverlight.

5 Javascript Debugging

It does not provide Javascript debugging.

It provides Javascript debugging.

6 LINQ Support

It does not support LINQ. It Supports Language Integrated Query (LINQ).

For further updates,please visit my below provided blog

http://onlydifferencefaqs.blogspot.in/