Skip to main content

Difference between WCF and Web API

Difference between WCF and Web API

WCF ships with .NET Framework only Web API ships with .NET framework as well as open source
WCF Supports RESTful services but in limited manner Web API is very ideal to build RESTful services
WCF use attribute based programming model Web API maps http verbs to methods
WCF supports reliable transaction and messaging Web API doesn’t support reliable transaction and messaging
WCF supports tcp, udp, http protocol and also custom transport protocol It supports only http protocol
WCF uses Operation, Data contracts and services Web API uses routing, controller, action methods etc, same to Asp.Net MVC

Understand the value type and reference type

In previous article we have seen difference between primary key and unique key. Today we will see the difference between value type and reference type.

Let first see what are the value types and what are the reference types.

What are Value Types?
Variables which stores direct data are called value types they are stored on a stack. They contains the actual value rather then reference.
For an example enum, structure int are value types.

What are Reference Types?
Variables which stores reference of actual data are called Reference types. They are stored on heap but contain the address on heap.
For an example Array, class, object, string, delegate, interface are reference type.

Now lets see the difference between both of them.

Before that let me show you the difference between Stack and Heap

Difference between Stack and Heap

Stack Heap
Stack is used for value types. Heap is used for reference types
Values are stored one on another like a stack Values are stored in random dumped into a big space

Difference between value type and reference types

Value Type Reference Type
Value Type are stored on stack Reference Type are stored on heap
It contains actual value It contains reference of a value
For value type memory is allocated at compile time For reference type memory is allocated at run time
Once they go out of scope it will automatically removed from stack, so no need for garbage collector. In reference type it required garbage collector to free the memory.
If value type is null able then only it contains null value, otherwise not Reference Type can contain null values.

That’s it.

Difference between Primary Key and Unique Key in SQL Server

In our previous article we have see the difference between Asp.Net Web Form and Asp.Net MVC, today we will see the difference between PK and UK.

Difference between Primary Key and Unique Key in SQL Server

Primary Key Unique Key
Primary Key creates a Clustered index Unique Key creates a Non Clustered Index
Primary Key does not allow null value Unique Key allows only 1 null value.
A table can have only 1 Primary Key A table can have more then 1 Primary Key
Primary Key is a unique key identifier of the record Unique-key is to prevent duplicate values in a column
Primary Key has to be unique. Unique Key does not have to be the primary key.
In Primary Key column you can’t delete or change the value In Unique Key column you can delete or changes it’s value

I love to here from you if I miss any other difference then listed above.