16 April 2011

Generics in .Net Framework

Generics in .Net Framework

Used to Reduced run-time errors,The compiler cannot detect type errors when you cast
to and from the Object class.the runtime will throw an exception

Using generics allows the compiler to catch this type of bug before your program runs

Generics improves runtime Performance.

Eg:
// Add a double and an int using the Obj class
Obj ob = new Obj(10.125, 2005);
Console.WriteLine((double)ob.t + (int)ob.u);

// Add a double and an int using the Gen class
Gen gb = new Gen(10.125, 2005);
Console.WriteLine(gb.t + gb.u);

If you run that code in a console application, the Obj and Gen classes produce exactly
the same results. However, the code that uses the Gen class actually works faster
because it does not require boxing and unboxing to and from the Object class.

Commonly used interfaces in .Net

Commonly used interfaces
Class Description

IComparable
-----------
Implemented by types whose values can be ordered; for example, the numeric and string classes. IComparable is required for sorting.

IDisposable
-----------
Defines methods for manually disposing of an object. This interface is important for large objects that consume resources, or objects that lock access to resources such as databases.

IConvertible
------------
Enables a class to be converted to a base type such as Boolean,Byte, Double, or String.

ICloneable
----------
Supports copying an object.

IEquatable
----------
Allows you to compare to instances of a class for equality. For example, if you implement this interface, you could say “if (a == b)”.

IFormattable
------------
Enables you to convert the value of an object into a specially formatted string. This provides greater flexibility than the base ToString method.

15 April 2011

Disable remember password option in Firefox/Internet Explorer In Code

Disable remember password option in Firefox/Internet Explorer In Code

For Disable remember password option in Firefox/Internet Explorer In Form
<form id="loginForm" autocomplete="off">
</form>

For Disable remember password option in Firefox/Internet Explorer In Particular Controls
<asp:TextBox ID="TextBox1" autocomplete="off" runat="server" TextMode="Password">

26 January 2011

WCF VS Web Services

WCF VS Web Services

Rich Set of Protocol
WCF supports more protocols for transporting messages than ASP.NET Web services. ASP.NET Web services only support sending messages by using the Hypertext Transfer Protocol (HTTP). WCF supports sending messages by using HTTP, as well as the Transmission Control Protocol (TCP), named pipes, and Microsoft Message Queuing (MSMQ). More important, WCF can be extended to support additional transport protocols. Therefore, software developed using WCF can be adapted to work together with a wider variety of other software, thereby increasing the potential return on the investment.

WCF provides much richer facilities for deploying and managing applications than ASP.NET Web services provides. In addition to a configuration system, which ASP.NET also has, WCF offers a configuration editor, activity tracing from senders to receivers and back through any number of intermediaries, a trace viewer, message logging, a vast number of performance counters, and support for Windows Management Instrumentation.

WPF vs. Silverlight in .net

WPF vs. Silverlight in .net

Both WPF and Silverlight use XAML (Extensible Application Markup Language) under the covers.

Let's look at some of the different characteristics of each technology:


WPF:

* Ships as part of the .NET Framework (version 3.0 and onward)
* Runs as Windows application or as web "browser application" (called XBAP, for "XAML Browser Application"). Note that XBAPs run only in Internet Explorer with .NET 3.0 and in both Internet Explorer and Firefox with .NET 3.5.
* Runs on Windows machines only (Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008)
* Richest functionality, including 3D graphics

Silverlight:

* Ships independently
* Runs in web browsers only (Internet Explorer, Firefox, Safari)
* Runs on Windows or Mac operating systems (also on Linux via Moonlight,which is an open source implementation of Silverlight based on Mono)
* Functionality is a subset of WPF's feature set

WPF is a more mature technology and was designed with a richer feature set. It also has the advantage of being able to run in a browser or as an installed Windows-Form-type app.

Silverlight has a broader reach.You can access Silverlight from many operating systems and web browsers.

The most important reason to choose one over the other should be based on the intended audience for the application. For example, if a corporation is designing an application for internal use only and every employee has Windows XP as the company standard OS, then go with WPF to leverage the richer feature set. If a corporation is designing an external-facing website, then Silverlight is the better choice because potential customers can access the website from a variety of different operating systems and browsers.

Base Class of all classes in the .NET Framework

Base Class of all classes in the .NET Framework

Object Class is Base Class of all classes in the .NET Framework

Implementing OAuth validation in a Web API

 I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...