Thursday, December 22, 2011

Monday, December 19, 2011

प्रेम करायचं राहुन गेलं

पाचवी पर्यंत प्रेम म्हणजे काय असतं ते माहीतच नव्हतं...
म्हणुन प्रेम करायचं राहुन गेलं.

दहावी पर्यंत अभ्यास,अभ्यास आणि अभ्यास...
म्हणुन प्रेम करायचं राहुन गेलं.

आता थोड तरी कळायला लागलं होत की प्रेम म्हणजे काय असतं,पण बारावी म्हणजे
आयुष्याच वळण...
म्हणुन प्रेम करायचं राहुन गेलं.

शाळेत असताना मुलीशी जास्त मैत्री कधी साधलीच नाही
त्यामुळे कॉलेज मध्ये सुध्दा मैत्री जपताच आली नाही...
म्हणुन प्रेम करायचं राहुन गेलं.

आता मैत्रीनीही खुप आहेत, पण प्रपोज करायला डेअरींगच होत नाही...
म्हणुन प्रेम करायचं राहुन गेलं.

प्रत्येक वेळा समोरच्यांच्या भावनांचा विचार केला, नाही म्हणाली तर
कदाचित चांगली मैत्रींन गमवून बसेन...
म्हणुन प्रेम करायचं राहुन गेलं.

कधी वाटत ह्या मुलींच्या मनातल सगळ कळाल असत तर बरं झाल असत ना!... पण ते
कधी कळालचं नाही...
म्हणुन प्रेम करायचं राहुन गेलं.

हल्ली पवईलेकवरच्या प्रेमीयुगुलांना पहातोना.. जीव खुप जळतो रे.. शपथ...
म्हणुन प्रेम करायचं राहुन गेलं.

नंतर विचार करतो अजुन लग्नाला दोन वर्षे आहेतं खुप वेळ आहे!
अजुन वेळ गेलेली नाही मित्रा.. काही तरी कर
पण काय करु कुणी मला प्रपोज करतच नाही .

पहिला दिवस...

me and ....
पहिला दिवस...

अजूनही आठवतोय मला तो पहिला दिवस...!
ज्या दिवशी आम्ही दोघे पहिल्यांदा भेटलो होतो..!
तिला भेटण्याच्या अतुर्तेमध्ये मला त्या
आदल्या रात्री झोओप आली नाही
कधी एकदाची ती रात्र संपते... आणि
सकाळ होते.. आणि कधी एकदाचा
मी तिला भेटायला जातोय असं मला झाले होते.!
सकाळ झाली मी उठलो, अघोळ केली..!
फुटलेल्या आरशा समोर उभा राहून जुना पण,
स्वच असा ड्रेस मी घातलेला होता..!
केस व्यवसित करून तयार झालो.

आदल्या दिवशी मित्राकडून,
आणलेली सेंट ची अर्धी बॉटल मी,
माझ्या कपड्यावर ओतली.
तेवढ्यातच आई ने आवाज दिला,
नाश्ता तयार आहे खावून जा.

आईला मला नाश्ता नको असे,
बोलत मी खिशामध्ये हाथ घातला,
बघतो तर काय माझाकडे,
फक्त २ नच रुपये होते,
मी आईला कॉलेजची फी भरण्यासाठी ,
५०रुप्ये मागितले तर तिने नकार दिला,
मी तसाच निराश होवून निघालो,
जाता जाता शेजाऱ्यांच्या बागेतील,
एक लाल गुलाबाचे फुल चोरून घेतले.

कधीही लवकर कॉलेजला न जाणारा मी,
आज मात्र सगळ्याच्या अगोदर आलो होतो.
तिला भेटण्याचा एक एक क्षण,
जवळ जवळ येत होता तस-तशी,
माझा मनातली भीती वाढतच जात होती,
पण आज मी निचय करूनच आलो होतो की,
आज तिला विचारल्याशिवाय जायच नाही.

सकाळचे ८ वाजले ती ठरलेल्या वेळेप्रमाणे आली,
नि माझा समोर येवून उभी राहिली.
मी घाबरत घाबरत तिला गुड मोर्निंग बोललो,
तिने पण मला गुड मोर्निंग केले.
तेव्हा कुटे तरी मला थोडेसे बरे वाटले,
नंतर मी तिला बोललो ,
मला तुला काही तरी सांगायचे आहे,
ती लाजत लाजत बोली "बोल"
मी डोळे मिटून धीर धरून तिला
आय लव यु ...! म्हटलं.

तसं तिने खाली वाकून sandal,
पकडणार एवढ्यातच मी तीचापासून,
दूर अंतरावर गालावरती हाथ ठेवून उभा,
राहिलो पण ती sandal ची पट्टी लावत ,
मला सेम टु यु...!!! म्हणाली.

Saturday, December 10, 2011

तो क्षण

मला पुन्हा एकदा तो क्षण जगायचा आहे

खरच मला पुन्हा एकदा शालेत जायचे आहे

शाळेच्या त्...या शेवटच्या बाकावर बसायचे आहे

नविन वही आणि नविन दप्तरचा सुगंध अनुभवायचा आहे

खणखणीत आवाजात पुन्हा पसायध्यान अन राष्ट्गीत मनायचे आहे

मला खरच पुन्हा एकदा तो क्षण जगायचा आहे

आभ्यास केला नाय म्हणुन गुरुजीचा सापाटुण मार खायचा अहे

जोर जोरजोरात बे चे पाढे मणायचे आहे

खिङकीतुन कोसळणनारा पाऊस अन त्यामुळे गळनारी कवले पुन्हा एकदा पाहयची आहेत

मला पुन्हा एकदा तो क्षण जगायचा आहे

दुपारच्या सुटीत आनलेला डबा सगळ्याना वाटुण खायचा आहे अन वाटताना सुध्दा
तो डबा सांडवतच खायचा आहे

पाणी प्यायला त्याच नळावर रांग लाउन ओजळीने पाणी प्यायचे आहे त्यातसुध्दा
पहिले पाणी पिण्यावरुण पार लोळसतोवर मारामारी कारायची आहे

खरच मला पुन्हा एकदा शालेत जायचे आहे

पी.टी.च्या तासाला मला पुर्ण मैदानभर हुदडायचे आहे

दमुण जाततोपर्यत खेळायच्ये आहे

शाळेची घंटा वाजल्यावर पहिले दप्तर घेऊन बाहेय पलायचे आहे

मला पुन्हा एकदा तो क्षण जगायचा आहे

खरच मला पुन्हा एकदा अन एकदा शालेत जायचे आहे

Thursday, December 8, 2011

count characters



This free script provided by JavaScript Kit

Monday, December 5, 2011

आयुष

आयुष्यात स्वप्ने पाहताना,
          वास्तवाला विसरायच नसत,
गुलाबाला स्पर्श करताना,
          काट्याच भान मात्र ठेवायचं आसत,
उधवस्त झालेलं जीवन,
          शून्यतून उभं करायचं आसत,
शत्रूशी लढताना,
          त्याला कमजोर कधी समजायचं नसत,
ख्यालेल्या मिठाला,
          जिवाभावाच्या मित्राला,
                    कधी विसरायच नसत,
आणि आई-वडिलांचे ऋण फेडल्या शिवाय,
          मरण्याचे नाव सुधा घ् याच नसत...

जीवनात चार गोष्टी

जीवनात चार गोष्टी परत भेटत नाहीत,
१) बोललेला शब्द
२) सोडलेला बाण
३) गत आयुष
४) सोडलेली सुसंधी...

Tuesday, November 1, 2011

VCricket


.Net Interview Questions And Answer

What is .NET?
.NET is essentially a framework for software development. It is similar in nature to any other software development framework (J2EE etc) in that it provides a set of runtime containers/capabilities, and a rich set of pre-built functionality in the form of class libraries and APIs
The .NET Framework is an environment for building, deploying, and running Web Services and other applications. It consists of three main parts: the Common Language Runtime, the Framework classes, and ASP.NET. 

CODE EXECUTION PROCES ASP.NET

STEP 1: Client sends request for the required file to the IIS (Webserver).
STEP 2: IIS will locate the requested file.
STEP 3: If requested file is found, IIS will submit that to ISAPI.dll
               ISAPI.dll is known as ASPX Engine.
               ISAPI means Internet Services Application Programming Interface.
STEP 4: ISAPI.dll will generate a Page Class file, by separating Client side
             code, Server side code & by adding required methods to execute the
             server side code.
STEP 5: This Page Class is submitted to Compilers (In case of
             pre-Compilation is not done).
STEP 6: Compilers will compile the Source Code & will generate MSIL code.
STEP 7: MSIL code will be submitted to CLR.
               CLR will perform 3 tasks here,
  1. Instantiation: Creates object to the respective Page Class
  2. Processing: Executes the Result/Code
  3. Rendering: Converts the Server side code into Client Understandable format (i.e., HTML and JAVASCRIPT).
STEP 8: CLR will generate complete Execution Result.
STEP 9: Execution Result will be delivered to IIS.
STEP 10: IIS will deliver the result to CLIENT.



OPPs Concepts
The skeleton of object - oriented  programming is of course the concepts of class. This C# tutorial on OOPS explains classes and their importance in implementation of object oriented principles.
   Any language can be called object oriented if it has data and method that use data encapsulated in items named objects. An object oriented programming method has many advantages, some of them are flexibility and code reusability. Object oriented Programming will be supporting these three main concepts:
  1. Encapsulation
  2. Inheritance
  3. Polymorphism

Encapsulation in C#:

   Encapsulation is process of keeping data and methods together inside objects. In this way developer must define somemethods of object's interaction. In C# , encapsulation is realized through the classes. A Class can contain data structures and met
public class Aperture
{
public Aperture()
{

}

protected double height;
protected double width;
protected double thickness;

public double GetVolume()
{

double volume = height*width*thickness;
if(volume<0)
return 0;
return volume;
}
}


   In this example we encapsulate some data such as height, width, thickness and method GetVolume. Other methods or objects can interact with this object through methods that have public access modifier. It must be done using . operator.

Inheritance in C#:

   In a few words, Inheritance is the process of creation new classes from already existing classes. The inheritance feature allows us to reuse some parts of code. So, now we have some derived class that inherits base class's members. Consider the following code snippet:


public class Door : Aperture
{

public Door() : base()
{

}

public bool isOutside = true;
}
   As you see to inherit one class from another, we need to write base class name after : symbol. Next thing that was done in code Door () constructor also inherits base class constructor. And at last we add new private field. All members of Aperture class are also in Door class. We can inherit all the members that has access modifier higher than protected.

Polymorphism in C#:

   Polymorphism is possibility to change behavior with objects depending of object's data type. In C# polymorphism realizes through the using of keyword virtual and override. Let look on the example of code:


public virtual void Out()
{
   Console.WriteLine("Aperture virtual method called");
}
//This method is defined in Aperture class.
public override void Out()
{
   Console.WriteLine("Door virtual method called");
}

   Now we need to re-define it in our derived Door class. The usage of virtual methods can be clarified when we creating an instance of derived class from the base class:
Aperture ap = new Door();
ap.Out();
   In such cases, the runtime keeps record of all the virtual function details in a table called VMT(Virtual Method Table) and then in runtime dynamically picks the correct version of the function to be used. Here it uses Out() method from derived class of course.

How many languages .NET is supporting now?
When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported. 

How is .NET able to support multiple languages?
A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language. 

How ASP .NET different from ASP?
Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server. 

What is smart navigation?
The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed. 

What is view state?
The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control 

How do you validate the controls in an ASP .NET page?
Using Page.Validate(). It is strictly validate All the validation control. 

Can the validation be done in the server side? Or this can be done only in the Client side?
Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.

How to manage pagination in a page?
Using pagination option in DataGrid control. Set the AllowPaging=True;  We have to set the number of records for a page, then it takes care of pagination by itself. 



Explain the life cycle of an ASP .NET page.?

Following are the events occur during ASP.NET Page Life Cycle:



1)Page_PreInit

2)Page_Init

3)Page_InitComplete

4)Page_PreLoad

5)Page_Load

6)Control Events

7)Page_LoadComplete

8)Page_PreRender

9)SaveViewState

10)Page_Render

11)Page_Unload


Among above events Page_Render is the only event which is raised by page. So we can't write code for this event.


Describe the complete lifecycle of a Web page?
When we execute a Web page, it passes from the following stages, which are collectively known as Web page lifecycle:


  • Page request - During this stage, ASP.NET makes sure the page either parsed or compiled and a cached version of the page can be sent in response
  • Start - During this stage sets the Request and Response page properties and the page check the page request is either a postback or a new request
  • Page Initialization - During this stage, the page initialize and the control's Unique Id property are set
  • Load - During this stage, if the request is postback, the control properties are loaded without loading the view state and control state otherwise loads the view state
  • Validation - During this stage, the controls are validated
  • Postback event handling - During this stage, if the request is a postback, handles the event
  • Rendering - During this stage, the page invokes the Render method to each control for return the output
  • Unload - During this stage, when the page is completely rendered and sent to the client, the page is unloaded. 
What are the events that happen when a client requests an ASP.NET page from IIS server?
The following events happen when a client requests an ASP.NET page from the IIS server:
  1. User requests for an application resource.
  2. The integrated request-processing pipeline receives the first user request.
  3. Response objects are created for each user request.
  4. An object of the HttpApplication class is created and allocated to the Request object.
  5. The HttpApplication class processes the user request.
In which event are the controls fully loaded?
Page load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that view state is not fully loaded during this event

How can we identify that the Page is Post Back?
Page object has an "IsPostBack" property, which can be checked to know that is the page posted back.


What is the lifespan for items stored in ViewState?
The items stored in ViewState live until the lifetime of the current page expires including the postbacks to the same page.

What is the difference between Finalize() and Dispose()?
Dispose() is called by as an indication for an object to release any unmanaged resources it has held. 
Finalize() is used for the same purpose as dispose however finalize doesn’t assure 
the garbage collection of an object.


What is the difference between Debug.Write and Trace.Write? When should each be used?
Debug.Write: Debug Mode, Release Mode (used while debuging a project)
Trace.write: Release Mode (used in Released verion of Applications)


How to prevent a class from being inherited in C#.NET?
The sealed modifier is used to prevent derivation from a class. An error occurs if a sealed class 
is specified as the base class of another class. A sealed class cannot also be an abstract class.


What are generics in C#.NET?
Generic types to maximize code reuse, type safety, and performance. They can be used to create 
collection classes. Generic collection classes in the System.Collections.Generic namespace should be 
used instead of classes such as ArrayList in the System.Collections namespace.


What is the difference between const and readonly in C#.NET?
The read only can be modified by the class it is contained in. However, the const cannot 
be modified. It needs to be instantiated only at the compile time.


What is the syntax to inherit from a class in C#?
Public class derivedclass:baseclass.


Can you inherit multiple interfaces?
Yes. .NET does support multiple interfaces.


What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The first one performs a deep copy of the array, the second one is shallow.


How can you sort the elements of the array in descending order?
By calling Sort() and then Reverse() methods.


What’s the .NET datatype that allows the retrieval of data by a unique key?
HashTable.

What is IIS? Why is it used?
Internet Information Services (IIS) is created by Microsoft to provide Internet-based services to ASP.NET Web applications. It makes your computer to work as a Web server and provides the functionality to develop and deploy Web applications on the server. IIS handles the request and response cycle on the Web server. It also offers the services of SMTP and FrontPage server extensions. The SMTP is used to send emails and use FrontPage server extensions to get the dynamic features of IIS, such as form handler.

What is Query String? What are its advantages and limitations?
The Query String helps in sending the page information to the server.
The Query String has the following advantages:
  • Every browser works with Query Strings.
  • It does not require server resources and so does not exert any kind of burden on the server.
The following are the limitations of Query String:
  • Information must be within the limit because URL does not support many characters.
  • Information is clearly visible to the user, which leads to security threats.
What is the GAC?
Each computer on which the common language runtime is installed has a machine-wide code cache called the 'Global Assembly Cache'. The global assembly cache (or GAC as it is commonly known) stores assemblies specifically designated to be shared by several applications on the computer. The global assembly cache is located in 'Windows/WinNT' directory and inherits the directory's access control list that administrators have used to protect the folder.
Assemblies installed in GAC should adhere to a specific versioning scheme that will allow them for side-by-side execution (multiple versions of the same assembly can be maintained in the GAC) of different code versions.
Shared Assemblies including all the important .NET System assemblies implementing the Framework Class Library reside within GAC. The GAC was originally called Fusion Cache and is implemented using Fusion.dll in .NET Framework.
Assemblies placed in the GAC must have the same assembly name and file name (not including the file name extension). For example, an assembly with the assembly name of 'myAssembly' must have a file name of either 'myAssembly.exe' or 'myAssembly.dll'.

What is tracing? Where is it used?
Tracing displays the details about how the code was executed. It refers to collecting information about the application while it is running. Tracing information can help you to troubleshoot an application. It enables you to record information in various log files about the errors that might occur at run time. You can analyze these log files to find the cause of the errors.
In .NET, we have objects called Trace Listeners. A listener is an object that gets the trace output and stores it to different places, such as a window, a file on your locale drive, or a SQL Server.
The System.Diagnostics namespace contains the predefined interfaces, classes, and structures that are used for tracing. It supplies two classes, Trace and Debug, which allow you to write errors and logs related to the application execution. Trace listeners are objects that collect the output of tracing processes.

What is the difference between authentication and authorization?
Authentication verifies the identity of a user and authorization is a process where you can check whether or not the identity has access rights to the system. In other words, you can say that authentication is a procedure of getting some credentials from the users and verify the user's identity against those credentials. Authorization is a procedure of granting access of particular resources to an authenticated user. You should note that authentication always takes place before authorization.


Differentiate globalization and localization?
The globalization is a technique to identify the specific part of a Web application that is different for different languages and make separate that portion from the core of the Web application. The localization is a procedure of configuring a Web application to be supported for a specific language or locale.

How does the cookies work in asp.net?
we know Http is an state-less protocol which is required for interaction between clinet and server .

so there is an need to remeber state of request raised by an web browser so that
web server can recognize you have already previously visited or not.
There are two types of state management techniques:
a) Client side state management
b) Server - side statemanagement

Using cookies comes under clinet side statemanagement .In HttpResponse we write
Cookie containing sessionId and other information within it.
when a browser made a request to the web server the same cookie is sent to the server where server recognize the session id and get other information stored to it previously.  

What is Ispostback method in ASP.Net? Why do we use that??
Basically Post back is an action performed by a interactive Webpage. When it goes to the server side for a non-client Operation Server again posts it back to the client and hence the name.
Ex:
if(!IsPostBack)
will not allow the page to post back again n again bcoz it reduces the performance.

Can User Control be stored in library?.
I will say "NO"

there are 3 types of controls:
1) User Control
2) Custom Control
3) Web parts

you can reuse User control in the current project in which you have built it, but you can't move it to other project as unless you just copy paste the same file there and make the changes for that project ( which violets the concept of library).

but custom control can be shared between projects. and you can precompile them even as a dll, so this means you can use them in library of any type.

what is the difference between application state and caching?
Application Object and Cached Object both falls under Server side State Management.

Application object resides in InProc i.e. on the same server where we hosted our application.
Cache Object resides on server side/ DownStream/Client Side.

Application Object will be disposed once application will stop.
Cache Object can be disposed using Time based cache dependency.

Only one user can access Application Object at a time hence we have to lock it every time we modify it.

What is boxing and unboxing?
Boxing is what happens when a value-type object is assigned to a reference-type variable.
Unboxing is what happens when a reference-type variable is assigned to a value-type variable.

What are the uses of Reflection??
Reflection is a concept using which we can

1) Load assemblies dynamically
2) Invoke methods at runtime
3) Retriving type information at runtime.

What is the use of AutoWireup in asp.net?
AutoEventWireup attribute is used to set whether the events needs to be automatically generated or not.
In the case where AutoEventWireup attribute is set to false (by default) event handlers are automatically required for Page_Load or Page_Init. However when we set the value of the AutoEventWireup attribute to true the ASP.NET runtime does not require events to specify event handlers like Page_Load or Page_Init.

What events will occur when a page is loaded?
Below are the events occures during page load.

1) Page_PreInit
2) Page_Init
3) Page_InitComplete
4) Page_PreLoad

Where is the View state Data stored?
ViewState data is stored in the hidden field. When the page is submitted to the server the data is sent to the server in the form of hidden fields for each control. If th viewstate of the control is enable true the value is retained on the post back to the client when the page is post backed.

What is the difference between custom web user control and a custom web server control?
Web User Control:
1) Easy to Create.
2) It Can be used inside the same Application.(To use it in other application we need to add it to that project.)
3) It Can take advantage of Caching Technique.

Web Server Control:
1) Bit tuff to create as compare to User Control.
2) Easy to use.
3) Can be added to ToolBox.

Where do the Cookie State and Session State information be stored?
Cookie Information will be stored in a txt file on client system under a
folder named Cookies. Search for it in your system you will find it.
Coming to Session State
As we know for every process some default space will be allocated by OS.
In case of InProc Session Info will be stored inside the process where our
application is running.
In case of StateServer Session Info will be stored using ASP.NET State Service.
In case of SQLServer Session info will be stored inside Database. Default DB
which will be created after running InstallSQLState Script is ASPState.

What is the difference between adding reference in solution Explorer and adding references by USING ?
Adding reference in solution explorer is used to add the DLL for that project for reference only. If you want to utilize that DLL methods/functions in our aspx.cs/.cs file etc you must write using that nameclass library name in file.

What are the different types of sessions in ASP.Net? Name them.?
Session Management can be achieved in two ways

1)InProc
2)OutProc

OutProc is again two types
1)State Server
2)SQL Server

InProcAdv.:
1) Faster as session resides in the same process as the application
2) No need to serialize the data
DisAdv.:
1) Will degrade the performance of the application if large chunk of data is stored
2) On restart of IIS all the Session info will be lost
State ServerAdv.:
1) Faster then SQL Server session management
2) Safer then InProc. As IIS restart
won't effect the session data
DisAdv.:
1) Data need to be serialized
2) On restart of ASP.NET State Service session info will be lost
3)Slower as compared to InProc
SQL ServerAdv.:
1) Reliable and Durable
2) IIS and ASP.NET State Service
restart won't effect the session data
3) Good place for storing large chunk of data
DisAdv.:
1) Data need to be serialized
2) Slower as compare to InProc and State Server
3)Need to purchase Licensed
version of SQL Serve

How do you design a website with multilingual support in ASP.NET?
Multilingual website can be created using Globalization and Localization.
Using Globalization we change the Currency Date Numbers etc to Language Specific Format.
To change the string which is there in the label button etc to language specific string we use Localization.
In Localization we have to create different Resource files for different languages.
During this process we use some classes present in System.Resources System.Globalization System.Threading namespaces.

What is caching? What are different ways of caching in ASP.NET?
Caching is a technique of persisting the data in memory for immediate access to requesting program calls. This is considered as the best way to enhance the performance of the application.

Caching is of 3 types:
Output Caching - Caches the whole page.
Fragment Caching - Caches a part of the page
Data Caching - Caches the data

what is delegate? Basically it is similar like the old "C" age function pointer, where functions can be assigned like a variable and called in the run time based on dynamic conditions. C# delegate is the smarter version of function pointer which helps software architects a lot, specially while utilizing design patterns.
At first, a delegate is defined with a specific signature (return type, parameter type and order etc). To invoke a delegate object, one or more methods are required with the EXACT same signature. A delegate object is first created similar like a class object created. The delegate object will basically hold a reference of a function. The function will then can be called via the delegate object.
Sounds easy? If not lets have a look in the code snippets below.
 1. Defining the delegate
 
public delegate int Calculate (int value1, int value2);

 2. Creating methods which will be assigned to delegate object
//a method, that will be assigned to delegate objects
//having the EXACT signature of the delegatepublic int add(int value1, int value2)
{
    return value1 + value2;            
}
//a method, that will be assigned to delegate objects
//having the EXACT signature of the delegatepublic int sub( int value1, int value2)
{
    return value1 - value2;            
}

 3. Creating the delegate object and assigning methods to those delegate objects
//creating the class which contains the methods 
//that will be assigned to delegate objectsMyClass mc = new MyClass();

//creating delegate objects and assigning appropriate methods
//having the EXACT signature of the delegateCalculate add = new Calculate(mc.add);
Calculate sub = new Calculate(mc.sub);

 4. Calling the methods via delegate objects
//using the delegate objects to call the assigned methods Console.WriteLine("Adding two values: " + add(10, 6));
Console.WriteLine("Subtracting two values: " + sub(10,4));

What is meant by 3-tier architecture.
We generally split our application into 3-Layers
1)Presentation Layer ( Where we keep all web forms Master Pages and User Controls).
2)Business Layer (Where we keep business logic). e.g Code related to manipulating data Custom Exception classes Custom Control classes Login related code if any etc. etc.
3)Data Access Layer (Where we keep code used to interact with DB). e.g. We can have the methods which are using SQL Helper (Application Block).

Explain the basic functionality of garbage collector?
Garbage Collector in .Net Framework is used for Automatic Memory Management i.e. it is collect all unused memory area and give to application. system.gc.collect() is a method for release the memory. But remember one think it is only an request i.e. we can't explicitly release the memory by using system.gc.collect().

What is the difference between mechine.config and web.config?
machine.config is a system level configuration i.e it is applied on all application in o/s that the configuration is set where as in web.config it is applicable to only one application i.e each asp.net webapplication will contain atleast on web.config file.

How can exception be handled with out the use of try catch?
using Exception Management application block
or
Page_error
Application_error objects

What is the difference between Response.Redirect and Server.Transfer.
Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server.Server.Transfer does not update the clients url history list or current url.
Response.Redirect is used toredirect the user's browser to another page or site. This performs a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.

Where the assembly is stored in asp.net?.
private are stored in application / bin directory and public are stored in GAC.

How we implement Web farm and Web Garden concept in ASP.NET?.
A web farm is a multi-server scenario. So we may have a server in each state of US. If the load on one server is in excess then the other servers step in to bear the brunt.
How they bear it is based on various models.
1. RoundRobin. (All servers share load equally)
2. NLB (economical)
3. HLB (expensive but can scale up to 8192 servers)
4. Hybrid (of 2 and 3).
5. CLB (Component load balancer).
A web garden is a multi-processor setup. i.e. a single server (not like the multi server above).
How to implement webfarms in .Net:
Go to web.config and
Here for mode you have 4 options.
a) Say mode inproc (non web farm but fast when you have very few customers).
b) Say mode StateServer (for webfarm)
c) Say mode SqlServer (for webfarm)
Whether to use option b or c depends on situation. StateServer is faster but SqlServer is more reliable and used for mission critical applications.
How to use webgardens in .Net:
Go to web.config and
Change the false to true. You have one more attribute that is related to webgarden in the same tag called cpuMask.

Is there any limit for query string? means what is the maximum size?..
Servers should be cautious about depending on URI lengths above 255 bytes because some older client or proxy implementations may not properly support these lengths.
Query string length depends on browser compatability

IE supports upto 255
Firefox supports upto 4000

What is the exact purpose of http handlers?
ASP.NET maps HTTP requests to HttpHandlers. Each HttpHandler enables processing of individual HTTP URLs or groups of URL extensions within an application. HttpHandlers have the same functionality as ISAPI extensions with a much simpler programming model
Ex
1.Default HttpHandler for all ASP.NET pages ->ASP.NET Page Handler (*.aspx)
2.Default HttpHandler for all ASP.NET service pages->ASP.NET Service Handler (*.asmx)
An HttpHandler can be either synchronous or asynchronous. A synchronous handler does not return until it finishes processing the HTTP request for which it is called. An asynchronous handler usually launches a process that can be lengthy and returns before that process finishes
After writing and compiling the code to implement an HttpHandler you must register the handler using your application's Web.config file.

What does the keyword virtual declare for a method? 
The method or property can be overridden.
 
What is the difference between an interface and abstract class ? 
1. In an interface class, all methods are abstract and there is no implementation.  In an abstract class some methods can be concrete.
2. In an interface class, no accessibility modifiers are allowed.  An abstract class may have accessibility modifiers. 
Ex.
An interface is defined using the keyword interface. It is common practice to start all interface names with a capital I. For example:
 
public interface IVehicle
{
  void Start();
  void Drive();
  void Park();
  void ChangeGear(int gear);
  void SwitchOff();
}
 
Note: In order to implement the interface, every method must be implemented in the class, else a compiler error will ensue. 
 
public class Vehicle : IVehicle
{
  public void Start()
  {
    Console.WriteLine("The vehicle has been started");
  }
 
  public void Drive()
  {
    Console.WriteLine("The vehicle is being driven");
  }
 
  public void Park()
  {
    Console.WriteLine("The vehicle is being parked");
  }
 
  public void ChangeGear(int gear)
  {
    Console.WriteLine("Gear changed to " + gear.ToString());
  }
 
  public void SwitchOff()
  {
    Console.WriteLine("The vehicle has been switched off");
  }
} 
 
 
Abstraction is defined using the keyword abstract, we could create an abstract class for all vehicle to inherit from:
public abstract class Vehicle
{
  public void Start()
  {
    Console.WriteLine("The vehicle has been started");
  }
 
  public abstract void Drive();
  public abstract void Park();
  public abstract void ChangeGear(int gear);
 
  public void SwitchOff()
  {
    Console.WriteLine("The vehicle has been switched off");
  }
}
 
So if we were to implement a Car class, it may look something like this.
 
public class Car : Vehicle
{
  public Car()
  {
  }
 
  public override void Drive()
  {
    Console.WriteLine("The car is being driven");
  }
 
  public override void Park()
  {
    Console.WriteLine("The car is being parked");
  }
 
  public override void ChangeGear(int gear)
  {
    Console.WriteLine("The car changed gear changed to " + gear.ToString());} 
Note: The override keyword tells the compiler that this method was defined in the base class.
Difference between array and Arraylist..

What is the difference between an Store Procedure and Function?
Functions
----------
1) can be used with Select statement
2) Not returning output parameter but returns Table variables
3) You can join UDF
4) Cannot be used to change server configuration
5) Cannot be used with XML FOR clause
6) Cannot have transaction within function

Stored Procedure
-----------------
1) have to use EXEC or EXECUTE
2) return output parameter
3) can create table but won’t return Table Variables
4) you can not join SP
5) can be used to change server configuration
6) can be used with XML FOR Clause
7) can have transaction within SP

What is the difference between an Array and Arraylist? 

ARRAY
ARRAYLIST
1.


Char[] vowel=new Char[];
ArrayList a_list=new ArrayList();
2.

Array is in the System namespace
ArrayList is in the System.Collections namespace.
3.


The capacity of an Array is fixed
ArrayList can increase and decrease size dynamically
4.
An Array is a collection of similar items
ArrayList can hold item of different types
5.
An Array can have multiple dimensions
 ArrayList always has exactly one dimension
6.

Array is a reference type data type. The array structure in System's Memory when you want to access the elements of an array through its index value location in an array,use an ArrayList.
The use of the arraylist is an alternative to the use of th array.
The Methods Of ArrayList class are
1)Add
2)Remove
3)Clear
4)Insert
5)TrimToSize
6)Sort
7)Reverse



What is the difference between an String and String-Builder?

Both String and StringBuilder are classes used to handle strings.


The most common operation with a string is concatenation. This activity has to be performed very efficiently. When we use the "String" object to concatenate two strings, the first string is combined to the other string by creating a new copy in the memory as a string object, and then the old string is deleted. This process is a little long. Hence we say "Strings are immutable".


When we make use of the "StringBuilder" object, the Append method is used. This means, an insertion is done on the existing string. Operation on StringBuilder object is faster than String operations, as the copy is done to the same location. Usage of StringBuilder is more efficient in case large amounts of string manipulations have to be performed.


What is the difference between an AJAX and JAVA SCRIPT?
When we view certain websites, we are after the data that is in it. And a whole page is normally not enough to hold everything we want to know, therefore there is a need to link the current page to the next one. But sometimes we don’t need to or even want to change the whole page, just the a certain section in it. For example, we have a shoutbox in a page, we wouldn’t want the whole page to reload whenever a new entry appears on the screen.
The first to provide this sort of functionality was Java, providing little compiled applets that can load data asynchronously. Later on, AJAX provided the standard the allowed coders to request data asynchronously in order to change the load new data without changing the web page.
Javascript, on the other hand, is a client side scripting language that allows the creation of dynamic web pages providing a new level of interactivity. The advantage of JavaScript is that since it’s a client side application, it can create dynamic web pages that are more complex than what a server side script can do. Server side scripts are run by the host machine and thus, has very limited resources especially when there are a lot of people accessing that server. Being on the client computer, Javascript has a lot of resources to play regardless of the activity on the server.


What is the difference between Array List And Hash Table?
1)In Array We Can Add any datatype value,Every item in 
arraylist is treated as object.
2)Hashtable is collection of key,value pairs 
   i)Key Can be any datatype
   ii)Key Cannot be null refrrence
   iii)but value can be null referrence
   
Retrieving by key in Hashtable is faster than retrieving in 
Arraylist,
Example of Arraylist:
Arraylist ar = new Arraylist();
          ar.add("X");
          ar.add(1);
          ar.add(2);
 Now if we Retrieve from Arraylist like
    foreach(string str in ar)
    {

    }
  It will Compile but it will give Runtime 
Error,because '1' and '2' in Arraylist are integers.

Example Hashtable:
         Hashtable ht = new Hashtable();
              ht.add(1,"sample");
              ht.add("2","Test");
              ht.add(3,4);
        foreach(Dictionaryentry dr in ht.keys.values)
          {
             Console.Writeline(dr.keys + "=" + dr.values);
          }

   The Above Code wont give any runtime Error Because We 
are iterating through DictionaryEntries(Hashtable 
implements IDictionary) it is Collection of Key/Value Pairs


ArrayList a = new ArrayList();
for (int i = 0; i < iterations; i++)
{
a.Add(i);
}


List<int> a = new List<int>();
for (int i = 0; i < iterations; i++)
{
a.Add(i);
}


Hashtable a = new Hashtable();
for (int i = 0; i < iterations; i++)
{
a.Add(i,i);
}


Dictionary<int, int> a = new Dictionary<int,int>();
for (int i = 0; i < iterations; i++)
{
a.Add(i, i);
}


namespace Example
{
    public partial class Examp: System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ABC a = new PQR();
            Response.Write(5);
        }
    }

    public abstract class ABC
    {
        public List<int> al = new List<int>();
        public ArrayList AL = new ArrayList();
        public Dictionary<int, string> dic = new Dictionary<int, string>();
        public Hashtable ht = new Hashtable();
        public void Setname()
        {
            for (int i = 0; i < 5; i++)
            {
                al.Add(i);
                AL.Add(i);
                dic.Add(i,i.ToString());
                ht.Add(i,i);
            }
        }
        public virtual void add()
        {
        }
    }

    class PQR : ABC
    {
        public void Setnameabc()
        {
            ABC a = new PQR();
            a.Setname();

        }
        //public override void add()
        //{
        //    throw new NotImplementedException();
        //}
    }
}

What are delegates?

Delegate and Event concepts are completely tied together. Delegates are just function pointers, That is, they hold references to functions.

A Delegate is a class. When you create an instance of it, you pass in the function name (as a parameter for the delegate's constructor) to which this delegate will refer.


Every delegate has a signature. For example:


Delegate int SomeDelegate(string s, bool b);


is a delegate declaration. When I say this delegate has a signature, I mean that it returns an int type and takes two parameters of type string and bool.


I said, when you instantiate delegates, you pass in the function name to which this delegate will refer as its constructor parameter. The important thing to notice is that only functions that have the same signature as the delegate, can be passed as a parameter.


Consider the following function:


private int SomeFunction(string str, bool bln){...}


You can pass this function to SomeDelegate's constructor, because of their similar signatures.


SomeDelegate sd = new SomeDelegate(SomeFunction);


Now, sd refers to SomeFunction, in other words, SomeFunction is registered to sd. If you call sd, SomeFunction will be invoked. Keep in mind what I mean by registered functions. Later, we will refer to registered functions.


sd("somestring", true);


Now that you know how to use delegates, let's understand events...


Understanding Events

  • A Button is a class, when you click on it, the click event fires.
  • A Timer is a class, every millisecond a tick event fires.


Want to understand what's happening? Let's learn through an example:


This is the scenario: we have a class named Counter. This class has a method named CountTo(int countTo, int reachableNum) which starts counting from 0 to countTo, and raises an event named NumberReached whenever it reaches the reachableNum.


Our class has an event: NumberReached. Events are variables of type delegates. I mean, if you want to declare an event, you just declare a variable of type some delegate and put event keyword before your declaration, like this:


public event NumberReachedEventHandler NumberReached;


In the above declaration, NumberReachedEventHandler is just a delegate. Maybe it was better to say: NumberReachedDelegate, but notice that Microsoft doesn't say MouseDelegate or PaintDelegate, instead it offers: MouseEventHandler and PaintEventHandler. It's a convention to say NumberReachedEventHandler instead of NumberReachedDelegate. OK? Good!


You see, before we declare our event, we need to define our delegate (our event handler). It could be something like this:


public delegate void NumberReachedEventHandler(object sender, 
    NumberReachedEventArgs e);


As you see, our delegate's name is: NumberReachedEventHandler, and its signature contains a void return value and two parameters of type object and NumberReachedEventArgs. If you somewhere want to instantiate this delegate, the function passed in as constructor parameter should have the same signature as this delegate.


Have you ever used PaintEventArgs or MouseEventArgs in your code to determine the position of the mouse, where it was moving, or the Graphics property of the object which raised the Paint event? Actually, we provide our data for the user in a class which is derived from EventArgs class. For example, in our example, we want to provide the number which was reached. And here is the class definition:


public class NumberReachedEventArgs : EventArgs
{
    private int _reached;
    public NumberReachedEventArgs(int num)
    {
        this._reached = num;
    }
    public int ReachedNumber
    {
        get
        {
            return _reached;
        }
    }
}


If it wouldn't be necessary to provide the user with any information, we just use the EventArgs class.


what is satellite assembly in .net?
satellite assemblies are used to build multi-linguestic 
applications. application which has built in supportive of 
more than one human readable language is known as multi-
lingustic applications.
satellite assembly is used to store a resource file in 
binary format; for this purpose we use resegn.exe and al.exe

resgen.exe convert a .resx file into resource file and then 
al.exe convert it into binary format and send it to 
satellite assembly;

 

Thread Synchronization using VS.NET 2005

Imagine the following lines of code:
Dim X as Integer
X = 1
X = X + 1
To a programmer the line X = X + 1 is a single operation. But consider this line from a computer’s perspective. Computers use machine language, which could mean many separate operations for each line of code. For example the line above could be broken down in to several operations, such as:Move the value of X into a register, move the value 1 into another register, add the two registers and place the value into a third register and finally move the added values into the memory address of the variable X.
Imagine the above situation with multiple threads trying to access the variable X at the same time. Synchronization is the process of eliminating these kinds of errors. Without synchronization programming, the computer could stop the first thread at any point in time, and let the second access the variable. If the second thread was incrementing X by 1 also, it might finish, and then the computer resumes the original thread that was running. This thread would restore its variable information, replacing the new X with the old value, nullifying the work that the second thread accomplished. This is called a race condition. These errors are very hard to find. It is best to put time in preventing them. .
To synchronize code, you utilize locks. A lock is a way to tell the computer that the following group of code should be executed together as a single operation, and not let other threads have access to the resource that is locked until the locking code is finished. In the case study, we will examine the different types of locks and objects that allow locking, and discuss when to use each method. When your code can handle multiple threads, safely, it is considered thread safe. This common term is used on code libraries and controls to designate that they are compatible with multiple threads.

 

Synchronization is achieved in C# through the use of Monitors. Monitor is a class present in System.Threading namespace. This class provides the synchronization of threading objects using locks and wait/signals.
Monitor has the following features:

  • Is associated with an object on demand.
  • Is unbound, i.e., can be called directly from any Context
  • Can not be instantiated.
Monitor exposes their ability to take and release the sync block lock on an object on demand via Enter, TryEnter and Exit.

The Wait, Pulse and PulseAll methods are related to SyncBlocks. It is necessary to be in a synchronized region on an object before calling Wait or Pulse on that object. Wait releases the lo9ck if it is held and waits to be notified. When Wait is notified, it returns and has obtained the lock again. Pulse signals for next thread in wait queue to proceed.

Monitor.Enter Method

The Monitor.Enter method obtains the monitor lock for an object. This method will block if another thread holds the lock. It will not block if the current thread holds the lock, however the caller must ensure that the same number of Exit calls are made as there were Enter Calls.

Enter the Monitor for an object. An object is passed as a parameter. This call will block if another thread has entered the Monitor of the same object. It will not block if the current thread has previously entered the Monitor, however the caller must ensure that the same number of Exit calls are made as there were Enter calls.

The general syntax for the Enter method is given as follows:


public static void Enter (object obj);


Where

obj represents an object on which to acquire the monitor lock.

The Thread.Interrupt method can interrupt threads waiting to enter a Monitor on an object. ThreadInterruptedException will be thrown if the thread was interrupted during a waiting state.

If another thread has executed an Enter on the object but not yet the corresponding Exit the current thread will block until the other thread releases the object. It is legal for the same thread to invoke Enter more then once (and it will not block); however, an equal number of Exit calls must be invoked before other threads waiting of the object will unblock.

Monitor.TryEnter Method

Similar to Enter, but will never block, or will only block for a certain amount of time.

Monitor.Exit Method

Releases the monitor lock. If one or more threads are waiting to acquire the lock, and the current thread has executed Exit, AS many times as it has executed Enter, one of the Treads will be unblocked and allowed to proceed.

The general syntax is given as follows:


public static void Exit(object obj);


Where

obj represents an object on which to release the monitor lock.

If the current thread owns the lock, the lock count is decremented for the specified object. If the count goes to zero (Exit has been executed as many times as Enter), other threads waiting on the object can acquire the lock.

Monitor.Wait Method

Waits for notifications passed by the Common Language Runtime from the object (via the Pulse or PluseAll method). The Wait method must be invoked from within a synchronized block of code

This method acquires the monitor withhandle for the object. If this thread holds the monitor lock for the object, it releases it. On exiting from the method, if obtains the monitor lock back.


What is Serialization?
Serialization is the process of converting complex objects into stream of bytes for storage. Deserialization is its reverse process, that is unpacking stream of bytes to their original form. The namespace which is used to read and write files is System.IO. For Serialization we are going to look at the System.Runtime.Serialization namespace. The ISerializable interface allows you to make any class Serializable.
Here are the following steps that we are going to do to create a serializable class and test it.
  • Create a custom class named Employee and assign properties.
  • Define the serialization functions.
  • Create a main class and instantiate our Employee class.
  • Serialize the object to a sample file.
  • Deserialize the values by reading it from the file.
Defining Employee class and properties
Our custom class Employee should be derived from the ISerializable interface and should hold the Serializable attribute. Here is the code snippet.

using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary; namespace MyObjSerial
{
[Serializable()] //Set this attribute to all the classes that want to serialize
public class Employee : ISerializable //derive your class from ISerializable
{
public int EmpId;
public string EmpName;

//Default constructor
public Employee()
{
EmpId = 0;
EmpName = null;
}
}
}

Different types of serialization.
The different types of serialization are
         Binary Serialization
         XML Serialization
         SOAP Serialization
Binary Serialization
Binary serialization is the process where you convert your .NET objects into byte stream. In binary serialization all the public, private, even those which are read only, members are serialized and converted into bytes. So when you want a complete conversion of your objects to bytes then one can make use of binary serialization.
XML Serialization
In XML serialization only the public properties and fields of the objects are converted into XML. The private members are not taken into consideration in XML serialization.
SOAP Serialization
Similar to XML serialization. When you serialize object to SOAP format it conforms to the SOAP specification.
Need of Serialization
Most uses of serialization fall into two categories: persistence and data interchange. Persistence allows us to store the information on some non-volatile mechanism for future use. This includes multiple uses of our application, archiving, and so on. Data interchange is a bit more versatile in its uses. If our application takes the form of an N-tier solution, it will need to transfer information from client to server, likely using a network protocol such as TCP. To achieve this we would serialize the data structure into a series of bytes that we can transfer over the network. Another use of serialization for data interchange is the use of XML serialization to allow our application to share data with another application altogether. As you can see, serialization is a part of many different solutions within our application.


Steps for Giving  strong name to DLL
Open .net command prompt.
  1. Go to the folder contanig DLL.
  2. Type sn -k test.snk, you can use any file name instead of test. This will create  test .snk file in that folder.
  3. Open the assemblyinfo.cs file of project.
  4. Type file path  in this tag [assembly:AssemblyKeyFile@"E:\hemant\practice\HP\bin\Debug\HP.snk")]
  5. Build  application, finally your strong name created for your DLL.
Example
  • Created class library path E:\hemant\practice\HP
  • Open command prompt go to Dll folder path.

  • Type sn -k HP.snk


This create  HP.snk file in E:\hemant\practice\HP\bin\Debug folder.

  • Open the  AssemblyInfo.cs file of project.

    Type  path  of snk file in following attribue.

  • Build class library.              
Steps for  Installing  in GAC

  • After giving strong name in .net command prompt type gacutil in DLL path
this will install file in assembly.



  • Copy the DLL file C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 folder.

  • You can add references  to another  project  using .net tab.

Convert Number to Words in CRYSTAL REPORT

If you number value is denoted by say {@ValueStr} then

Create a Formula Field Say "Num2Words" and Type the following formula.

"Rupees " + ToWords ({@ValueStr},0) + " and " + ToWords ((Round({@ValueStr},2) - Int({@ValueStr})) * 100, 0)

In the above formula
1. ToWords({@ValueStr},0)  first gets the Integer Part of the string only. 
2. ToWords ((Round({@ValueStr},2) - Int({@ValueStr})) * 100, 0)    extracts the decimal part rounded to 2 decimal places, converts to integer, and then to words.
 
The primary events for reports..
EventDescription
InitReport()Fired after a report has been successfully loaded. This is the only event available for the ReportDocument class. This is not available for the CrystalReportViewer class.
Drill()Fired when the user drills down on a field.
DrillDownSubReport()Fired when the user drills down on a subreport.
HandleException()Fired when an exception occurs.
Navigate()Fired when a user moves to another page on the report.
ReportRefresh()Fired when the user refreshes the report data.
Search()Fired when the user enters a search string.
ViewZoom()Fired when the user changes the zoom percentage.
 


WCF Interview Questions and Answer                    

Q1. What is WCF?
WCF stands for Windows Communication Foundation. It is a Software 
development kit for developing services on Windows. WCF is introduced in
.NET 3.0. in the System.ServiceModel namespace. WCF is based on basic 
concepts of Service oriented architecture (SOA)

Q2. What is endpoint in WCF service?
The endpoint is an Interface which defines how a client will communicate
with the service. It consists of three main points: Address,Binding and Contract.
Q3. Explain Address,Binding and contract for a WCF Service? Address:Address defines where the service resides. Binding:Binding defines how to communicate with the service. Contract:Contract defines what is done by the service. Q4. What are the various address format in WCF? a)HTTP Address Format:--> http://localhost: b)TCP Address Format:--> net.tcp://localhost: c)MSMQ Address Format:--> net.msmq://localhost: Q5. What are the types of binding available in WCF? A binding is identified by the transport it supports and the encoding it uses. Transport may be HTTP,TCP etc and encoding may be text,binary etc. The popular types of binding may be as below: a)BasicHttpBinding b)NetTcpBinding c)WSHttpBinding d)NetMsmqBinding Q6. What are the types of contract available in WCF? The main contracts are: a)Service Contract:Describes what operations the client can perform. b)Operation Contract : defines the method inside Interface of Service. c)Data Contract:Defines what data types are passed d)Message Contract:Defines wheather a service can interact directly with messages Q7. What are the various ways of hosting a WCF Service? a)IIS b)Self Hosting c)WAS (Windows Activation Service) Q8. WWhat is the proxy for WCF Service? A proxy is a class by which a service client can Interact with the service. By the use of proxy in the client application we are able to call the different methods exposed by the service Q9. How can we create Proxy for the WCF Service? We can create proxy using the tool svcutil.exe after creating the service. We can use the following command at command line. svcutil.exe *.wsdl *.xsd /language:C# /out:SampleProxy.cs /config:app.config Q10.What is the difference between WCF Service and Web Service? a)WCF Service supports both http and tcp protocol while webservice supports only http protocol. b)WCF Service is more flexible than web service.
Difference between WCF and Web services?
Web Services can be accessed only over HTTP
Web Services works in stateless environment
WCF is flexible because its services can be hosted in different types of applications.
The following lists several common scenarios for hosting WCF services: 
IIS WAS Self-hosting Managed Windows Service
 
What are the various ways of hosting a WCF service?
Self hosting the service in his own application domain. This we have already covered in the first section. The service comes in to existence when you create the object of ServiceHost class and the service closes when you call the Close of the ServiceHost class. Host in application domain or process provided by IIS Server. Host in Application domain and process provided by WAS (Windows Activation Service) Server.
 
What are three major points in WCF?
We Should remember ABC.
Address - Specifies the location of the service which will be like http://Myserver/MyService.Clients will use this location to communicate with our service.
Binding - Specifies how the two paries will communicate in term of transport and encoding and protocols.
Contract - Specifies the interface between client and the server.It's a simple interface with some attribute.
            
What was the code name for WCF?
The code name of WCF was Indigo . WCF is a unification of .NET framework communication technologies which unites the following technologies:- NET remoting MSMQ Web services COM+

What are the main components of WCF?
The main components of WCF are 1. Service class 2. Hosting environment 3. End point

What are different elements of WCF Srevices Client configuration file?
WCF Services client configuration file contains endpoint, address, binding and contract.
A sample client config file looks like

What is Proxy and how to generate proxy for WCF Services?
WCF Services client configuration file contains endpoint, address, binding and contract.
A sample client config file looks like The proxy is a CLR class that exposes a single CLR interface representing the service contract. The proxy provides the same operations as service's contract, but also has additional methods for managing the proxy life cycle and the connection to the service. The proxy completely encapsulates every aspect of the service: its location, its implementation technology and runtime platform, and the communication transport.
The proxy can be generated using Visual Studio by right clicking Reference and clicking on Add Service Reference. This brings up the Add Service Reference dialog box, where you need to supply the base address of the service (or a base address and a MEX URI) and the namespace to contain the proxy. Proxy can also be generated by using SvcUtil.exe command-line utility. We need to provide SvcUtil with the HTTP-GET address or the metadata exchange endpoint address and, optionally, with a proxy filename. The default proxy filename is output.cs but you can also use the /out switch to indicate a different name.

What are contracts in WCF?
In WCF, all services expose contracts. The contract is a platform-neutral and standard way of describing what the service does. WCF defines four types of contracts.
Service contracts Describe which operations the client can perform on the service. There are two types of Service Contracts. ServiceContract - This attribute is used to define the Interface. 
OperationContract - This attribute is used to define the method inside Interface.
[ServiceContract]
interface IMyContract
{
[OperationContract]
string MyMethod( );
}
class MyService : IMyContract
{
public string MyMethod( )
{
return "Hello World";
}
}
Data contracts
Define which data types are passed to and from the service. WCF defines implicit contracts for built-in types such as int and string, but we can easily define explicit opt-in data contracts for custom types.
There are two types of Data Contracts.
DataContract - attribute used to define the class
DataMember - attribute used to define the properties.
[DataContract]
class Contact
{
[DataMember]
public string FirstName;
[DataMember]
public string LastName;
}
If DataMember attributes are not specified for a properties in the class, that property can't be passed to-from web service. 

What is the address formats of the WCF transport schemas?
Address format of WCF transport schema always follow [transport]://[machine or domain][:optional port] format. for example: HTTP Address Format http://localhost:8888 the way to read the above url is "Using HTTP, go to the machine called localhost, where on port 8888 someone is waiting" When the port number is not specified, the default port is 80. TCP Address Format net.tcp://localhost:8888/MyService When a port number is not specified, the default port is 808: net.tcp://localhost/MyService NOTE: Two HTTP and TCP addresses from the same host can share a port, even on the same machine. IPC Address Format net.pipe://localhost/MyPipe We can only open a named pipe once per machine, and therefore it is not possible for two named pipe addresses to share a pipe name on the same machine. MSMQ Address Format net.msmq://localhost/private/MyService net.msmq://localhost/MyService

What is endpoint in WCF?
Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service. In WCF the relationship between Address, Contract and Binding is called Endpoint. The Endpoint is the fusion of Address, Contract and Binding.

Where we can host WCF services?
Every WCF services must be hosted somewhere. There are three ways of hosting WCF services.
They are
1. IISM
2. Self Hosting
3. WAS (Windows Activation Service)

What is service and client in perspective of data communication?
A service is a unit of functionality exposed to the world.
The client of a service is merely the party consuming the service