Pages

Thursday, February 27, 2014

C# Interview Questions:

1) What are the advantages of C# over C ,C++ ,Java?

Like C++ and Java, C# is a high-level object-oriented programming language. It is generally more efficient than Java and has useful features such as operator overloading. C# is based on C++ but has several advantages over this older language: it is type-safe, more comprehensively object-oriented, and the syntax has been simplified in several important ways. Most importantly, C# interoperates exceptionally well with other languages on the .NET platform. For this reason, C# is a better choice for building applications for .NET.

2)How are NameSpaces are used in C#?

Classes in the .NET framework can be organized using namespaces. The scope of a class is declared using the namespace keyword. You can then include methods from the namespace in your code by including the line “using [namespace];” at the start of your program.

3)What is a Constructor?

A constructor is the method of a class that is called when an object of that class is created. The constructor initializes class parameters and has the same name as the class.



Thursday, February 13, 2014

Difference between Response.redirect() & Server.Transfer() ?

Response.Redirect

  • Response.Redirect() will send you to a new page, update the address bar and add it to the Browser History. On your browser you can click back.
  • It redirects the request to some plain HTML pages on our server or to some other web server.
  • It causes additional roundtrips to the server on each request.
  • It doesn’t preserve Query String and Form Variables from the original request.
  • It enables to see the new redirected URL where it is redirected in the browser (and be able to bookmark it if it’s necessary).
  • Response. Redirect simply sends a message down to the (HTTP 302) browser.
Server.Transfer
  • Server.Transfer() does not change the address bar, we cannot hit back.One should use Server.Transfer() when he/she doesn’t want the user to see where he is going. Sometime on a "loading" type page.
  • It transfers current page request to another .aspx page on the same server.
  • It preserves server resources and avoids the unnecessary roundtrips to the server.
  • It preserves Query String and Form Variables (optionally).
  • It doesn’t show the real URL where it redirects the request in the users Web Browser.
  • Server.Transfer happens without the browser knowing anything, the browser request a page, but the server returns the content of another.

What is .Net Framework?

Introduction

.Net Framework is the first step to enter in to the .Net world. A framework can be defined as building blocks. Similarly .Net Framework can be defined as Building blocks of any .Net application. The .Net framework contains set of assemblies (in .Net we call all the DLLs as Assemblies) to support different kind of .Net applications (may be windows based, web based and other applications). Depending upon the kind of application we would like to develop we can use the corresponding Assemblies available in the .Net Framework. .Net Framework also contains some Assemblies to execute the .Net application. So .Net Framework is the collection of Assemblies to support the .Net application development and .Net application execution.

The Word .Net:-

We know that .Net Framework is a collection of Assemblies. Now let us know what does the word .Net mean? There is no reason given by Microsoft for the word ".Net", but you can see some definitions over the web saying that it is "Network of all technologies", "Next Generation Technology" and so.

Why do you need .Net?

We have so many technologies available over the world. Now why do we need one more technology called .Net? Why should I go for .Net? The answer for this question can be

1. Automatic Memory Management

2. Web Services

3. Easy Deployment

4. Interoperability

5. Net Language Independent

Let's look on each briefly,

Automatic Memory Management:-

The most expensive problem the current VC++ programmers are facing would be 'memory leak'. To be clear, every new operator we use in our program should be matched with a delete operator. i.e. if we allocate memory for an object using new keyword then it should be deallocated using the delete operator. If we forget to apply delete operator then the memory allocated using the new operator cannot be used for other purposes. This is called memory leak. In .net there is no place for the term memory leak, because we don't have to use delete operator on any object. We can use the new keyword, and forget about delete. .Net will automatically delete the object when that particular object is no longer used or referenced.

Web Services:-

Web Services are standardized way to communicate between two entities/processes over web. This uses XML(eXtensible Markup Language), WSDL (Web Service Description Language), SOAP (Simple Object Access Protocol), and UDDI (Universal Description, Discovery and Integration). We can think of this web services as similar to windows services but this web services can also be accessed from any where over web. .Net has full support to the web services comparing other technologies.

Easy Deployment:-

In case of .Net applications, the deployment is just a copy and paste. Because all the .Net assemblies are 'self describing'. We don't need to depend on any header file or registry (like COM components) or others. Just by copying the files and pasting it in a different machine will complete the deployment. (However any shared assemblies should be installed into a special folder called 'assembly').

Interoperability:-

Interoperability can be defined as the ability of a hardware/software to share data between two applications on different/same machine. Consider we have two applications one is developed in VC++ and other one is developed in VB. It is not possible to share the data (with out any special mechanism) from one application to another application as the data type used in one language cannot be understood by other application.
Most of the applications running now a day were developed using C, C++, COM etc. Moving towards .Net technology, it is not possible to recreate all the application developed in other technologies so far. For that purpose .Net has provided a full support for .Net applications to interact with other applications and vice versa. Any COM component or Win32 application can be communicated easily with .Net application.

.Net Language Independent:-

Consider you are creating a DLL using VC++. Now what if you want use this DLL in VB application, we cannot use the DLL in VB, i.e. cross language interoperability is not supported. But in case of .Net languages you can create a DLL using C#.Net and use that DLL in VB.Net application. Similarly you can cross with any .Net languages. Note that only .Net languages can be crossed. VC++.Net and VC++ are not same (we will see the difference later).