Category Archives: .Net Question

Difference between visual studio 2005 and visual studio 2008

Difference between visual studio 2005 and  visual studio 2008

There are main some difference between .net2005 and .net2008

The visual studio .net 2005 support .Net framwork 2.0
The visual studio .net 2008 support .Net framwork 3.0

The major Difference are : visual studio .net 2008 includes

1) LINQ – Language Integrated Query

2) WCF and WPF concepts where xml is used.

3) AJAX Component are included.
– UpdatePanel
– Time Control
– ScriptManager
– UpdateProgress

4) more flexibility

5) Java Script Supports

Maintain scroll position after Postback is fired in ASP.Net C#

Maintain scroll position means After post back event fired the page position same as before.

There are many ways we can maintain scroll position after postback in


First Way: –

we can add below line on Page directive for a single page to maintain the previous scroll position when post back is fired.

<%@ Page MaintainScrollPositionOnPostback=”true” %>


Second Way:-

we can also write below code in code behind .aspx.cs file in ASP.Net

Page.MaintainScrollPositionOnPostBack = true;


Third Way : –

We can add below code in web.config file for set all page scroll position maintain.



<pages maintainScrollPositionOnPostBack=”true” />



Difference between .ToString() and Convert.Tostring() in .NET

Difference between .ToString() and Convert.Tostring() in .NET


The Major Difference between .ToString() and Convert.Tostring() is about NULL Exception.

The ToString() fails Converting object to string when the object is null.

We get error when the Object is NULL.


The Convert.Tostring() handle the NULL Object.

Convert.Tostring()handles null and not throws ObjectReferenceNullException.
Tostring() does not handles the null value and throws the null exception error message.

Here’s an example


public String YourName = null;

protected void Page_Load(object sender, EventArgs e)


Response.Write(“FullName :” + FullName.ToString());

catch (Exception ex)





Response.Write(“Your Name :” + Convert.ToString(YourName));

catch (Exception ex)





The RESULT is :

Object reference not set to an instance to an object.


Value Types and Reference Types in .Net

Value Types and Reference Types in .Net

A data type is a value type if it holds the data within its own memory allocation. A reference type contains a pointer to another memory location that holds the data.

All the data types in .net are classified in to value types and reference types.

  • The data types whose values are directly stored in stack memory area are called as value types and the data types whose values are stored in heap memory area and its address is stored in a variable in stack memory area are called as reference types.
  • Among all built in data types of .net string and object are reference type and all other data types are value types.
  • Among user defined data types, class, interface, delegate and arrays are reference type while structure and enumeration are value type.

Value Types
Value types include the following:

  • All numeric data types
  • Boolean, Char, and Date
  • All structures, even if their members are reference types
  • Enumerations, since their underlying type is always SByte, Short, Integer, Long, Byte, UShort, UInteger, or ULong

Reference Types
Reference types include the following:

  • String
  • All arrays, even if their elements are value types
  • Class types
  • Delegates

What is Boxing and Unboxing in C#

What is Boxing and Unboxing in C#


The Boxing and Unboxing are concept of Values Types and Reference Type.

Boxing :-
Boxing is conversion from Value Type to Reference Type (Object).
Converting a value type to reference type is called Boxing.


int m=125;

object p=m; // here we boxing m;
class MYTES

int i=1;
object o=i; // boxing
int j=(int) o; //unboxing


Unboxing: –
UnBoxing is conversion from Reference Type(Object) to Value Type.


m = 123;
i = (int)m;  // unboxing proccess

ASP.Net Interview Short Questions

ASP.Net Short Interview Questions

Differences between Server-side and Client-side code?
Server side code is executed at the server side on IIS in ASP.NET framework, while client side code is executed on the browser.

What’ is the sequence in which ASP.NET events are processed ?  1 Page_Init.
2 Page_Load.
3 Control events
4 Page_Unload event.
Page_init event only occurs when first time the page is started, but Page_Load occurs in subsequent request of the page.

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 viewstate is not fully loaded during this event.

How can we identify that the Page is PostBack ? 

Page object has a “IsPostBack” property which can be checked to know that is the page posted back.

What is event bubbling ?

Server controls like Datagrid, DataList, Repeater can have other child controls inside them. Example DataGrid can have combo box inside datagrid. These child control do not raise there events by themselves, rather they pass the event to the container parent (which can be a datagrid, datalist, repeater), which passed to the page as “ItemCommand” event. As the child control send there events to parent this is termed as event bubbling.

How do we assign page specific attributes ?

Page attributes are specified using the @Page directive.

What is the use of @ Register directives ?

@Register directive informs the compiler of any custom server control added to the page.

What’s the use of SmartNavigation property ?

It’s a feature provided by ASP.NET to prevent flickering and redrawing when the page is posted back.

What type of code (server or client) is found in a Code-Behind class?

Server side code.

How many ways can we maintain the state of a page?

1. Client Side – Query string, hidden variables, viewstate, cookies
2. Server side – application , cache, context, session, database

What is AppSetting Section in “Web.Config” file ?

Web.config file defines configuration for a webproject. Using “AppSetting” section we can define user defined values. Example below defined is “ConnectionString” section which will be used through out the project for database connection.

Where is ViewState information stored ?

In HTML Hidden Fields
How many types of validation controls are provided by ASP.NET ?
There are six main types of validation controls :-RequiredFieldValidator It checks whether the control have any value. It’s used when you want the control should not be empty.

 RangeValidator It checks if the value in validated control is in that specific range. Example TxtMobileNo should be ten digit length.

CompareValidator It checks that the value in controls should match the value in other control. Example compare password with confirm password in registration form.

RegularExpressionValidator When we want the control value should match with a specific regular expression. We use it in Email and website address format check in registration form.

CustomValidator It is used to define UserDefined validation.

ValidationSummary It displays summary of all current validation errors at one place on web forms.

How can you enable automatic paging in DataGrid ?

Following are the points to be done in order to enable paging in Datagrid :-
– Set the “AllowPaging” to true.
–  In PageIndexChanged event set the current pageindex clicked.
What is the difference between “Web.config” and “Machine.Config”?
“Web.config” files apply settings to each web application, while “Machine.config” file apply settings to all ASP.NET applications.
What is a SESSION and APPLICATION object ? 
Session object store information between HTTP requests for a particular user, while application object are global across users.
Explain the differences between Server-side and Client-side code?
Server side code is executed at the server side on IIS in ASP.NET framework, while client side code is executed on the browser.
What is Difference between NameSpace and Assembly?
Following are the differences between namespace and assembly :
– Assembly is physical grouping of logical units. Namespace logically groups classes.
– Namespace can span multiple assembly.
What is the difference between Convert.toString and .toString() method ?
int i =0;
We can convert the integer “i” using “i.ToString()” or “Convert.ToString” so what’s the difference. The basic difference between them is “Convert” function handles NULLS while “i.ToString()” does not it will throw a NULL reference exception error. So as good coding practice using “convert” is always safe.

What is difference between abstract classes and interfaces?
–  Abstract classes can have concrete methods while interfaces have no methods implemented.
– Interfaces do not come in inheriting chain, while abstract classes come in inheritance.

What is a CLR?

Full form of CLR is Common Language Runtime and it forms the heart of the .NET framework. All Languages have runtime and its the responsibility of the runtime to take care of the code execution of the program.
Following are the responsibilities of CLR
– Garbage Collection
– Code Access Security
– Code Verification
What is a IL?
(IL)Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. This IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In- Time (JIT) compiler.
What is a CTS?
In order that two language communicate smoothly CLR has CTS (Common Type System).Example in VB you have “Integer” and in C++ you have “long” these datatypes are not compatible so the interfacing between them is very complicated. In order to able that two different languages cancommunicate Microsoft introduced Common Type System. So “Integer” datatype in VB6 and “int” datatype in C++ will convert it to System.int32 which is datatype of CTS. CLS which is covered in the coming question is subset of CTS.
What is a CLS(Common Language Specification)?
This is a subset of the CTS which all .NET languages are expected to support. It was always a dream of Microsoft to unite all different languages in to one umbrella and CLS is one step towards that. Microsoft has defined CLS which are nothing but guidelines that language to follow so that it can communicate with other .NET languages in a seamless manner.
What is a Managed Code?
Managed code runs inside the environment of CLR i.e. .NET runtime. In short all IL are managed code. But if you are using some third party software example VB6 or VC++ component they are unmanaged code as .NET runtime (CLR) does not have control over the source code execution of the language.
What is a Assembly?
Assembly is unit of deployment like EXE or a DLL.
An assembly consists of one or more files (dlls, exe’s, html files etc.), and represents a group of resources, type definitions, and implementations of those types. An assembly may also contain references to other assemblies. These resources, types and references are described in a block of data called a manifest. The manifest is part of the assembly, thus making the assembly self-describing.
An assembly is completely self-describing.An assembly contains metadata information, which is used by the CLR for everything from type checking and security to actually invoking the components methods. As all information is in the assembly itself, it is independent of registry. This is the basic advantage as compared to COM where the version was stored in registry
What is NameSpace?
Namespace has two basic functionality :-
– NameSpace Logically group types, example System.Web.UI logically groups our UI related features.
– In Object Oriented world many times its possible that programmers will use the same class name.By qualifying NameSpace with classname this collision is able to be removed.
What is Manifest?
Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the following things (See Figure Manifest View for more details):
– Version of assembly
– Security identity
– Scope of the assembly
– Resolve references to resources and classes.
– The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a stand-alone PE file that contains only assembly manifest information.
Where is version information stored of an assembly ?
Version information is stored in assembly in manifest.
Is versioning applicable to private assemblies?
Versioning concept is only applicable to global assembly cache (GAC) as private assembly lie in their individual folders.
What is GAC ?
GAC (Global Assembly Cache) is used where shared .NET assembly reside. GAC is used in the following situations :-
– If the application has to be shared among several application.
– If the assembly has some special security requirements like only administrators can remove the assembly. If the assembly is private then a simple delete of assembly the assembly file will remove the assembly.
What is garbage collection?
Garbage collection is a CLR feature which automatically manages memory. Programmers forget to release the objects while coding ….. Laziness (Remember in VB6 where one of the good practices is to set object to nothing). CLR automatically releases objects when they are no longer in use and refernced. CLR runs on non-deterministic to see the unused objects and cleans them. One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when it goes out of the scope of a function. Therefore, we should not put code into a class destructor to release resources.
Can we force garbage collector to run ?
System.GC.Collect() forces garbage collector to run. This is not recommended but can be used if situations arises.
What is reflection?
 All .NET assemblies have metadata information stored about the types defined in modules. This metadata information can be accessed by mechanism called as “Reflection”.System.
Reflection can be used to browse through the metadata information. Using reflection you can also dynamically invoke methods using System.Type.Invokemember. Below is sample source code if needed you can also get this code from CD provided, go to “Source code” folder in “Reflection Sample” folder.
What are different types of JIT ?
JIT compiler is a part of the runtime execution environment.
In Microsoft .NET there are three types of JIT compilers:
– Pre-JIT :– Pre-JIT compiles complete source code into native code in a single compilation cycle. This is done at the time of deployment of the application.
– Econo-JIT :- Econo-JIT compiles only those methods that are called at runtime. However, these compiled methods are removed when they are not required.
– Normal-JIT :- Normal-JIT compiles only those methods that are called at runtime. These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the compiled code from cache is used for execution.
What are Value types and Reference types?
Value types directly contain their data which are either allocated on the stack or allocated in-line in a structure. Reference types store a reference to the value’s memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. Variables that are value types each have their own copy of the data, and therefore operations on one variable do not affect other variables. Variables that are reference types can refer to the same object; therefore, operations on one variable can affect the same object referred to by another variable. All types derive from the System.Object base type.
What is Boxing and Unboxing ?
Boxing permits any value type to be implicitly converted to type object or to any interface type implemented by value type. Boxing is a process in which object instances are created and copy values in to that instance. Unboxing is vice versa of boxing operation where the value is copied from the instance in to appropriate storage location. Below is sample code of boxing and unboxing where integer data type is converted in to object and then vice versa.
Dim x As Integer
Dim y As Object
x = 10
‘ boxing process
y = x
‘ unboxing process
x = y
What is the difference between Authentication and authorization?
Authentication is verifying the identity of a user and authorization is process where we check does this identity have access rights to the system. In short we can say the following authentication is the process of obtaining some sort of credentials from the users and using those credentials to verify the user’s identity. Authorization is the process of allowing an authenticated user access to resources. Authentication always proceed to Authorization; even if your application lets anonymous users connect and use the application, it still authenticates them as being anonymous.

Need of IIS and Step to Install IIS.

What is IIS (Internet Information Services)?

–  Internet Information Services is used to make your computer a web server. If we want to have a web server for developing dynamic website or want to publish website on our own server then we install the IIS. IIS is used on windows plateform. For other plate form we have different web servers. E.g. apache for Linux.
 – Internet Information Services is used to make your computer a web server. If we want to have a web server for developing dynamic website or want to publish website on our own server then we install the IIS. IIS is used on windows plateform. For other plate form we have different web servers. E.g. apache for Linux.

– Step to Install IIS

 – To install IIS you must have your operating systems CD
(Win XP or Win 2K).
–  Go to control panel and select “Add Remove Programs”.
–  From that window select “Add Remove Windows Components”.
–  After this you can see Internet Information Services checkbox.
– Select this and press OK.
– Installation will be started, during this installation it will ask you
to give the path of your Windows CD.
– Select from browse and give the path of Windows CD.  After some time the installation process will be done

What is difference between VB.Net and ASP.Net?

What is difference between VB.Net and ASP.Net?

Programming languages that Microsoft includes with Visual Studio are C#, Visual Basic, J#, and C++.
– is not a coding language. ASP.Net is a tools / technology for develop powerful web and windows application. It is a term to describe the (vast) area of the .net framework that allows you to write code directed to the web.
 – is a tool for developing a web and windows application using different languages.
– is different. It is one of several code languages that can communicate with the framework. Others include c# or j#.
-Vb.Net is a language.
– is one of several code languages that is compatible with the .net framework.

What is ASP and ASP.Net?

What is ASP and ASP.Net?

ASP – Active Server Pages or Classic ASP, as it is more commonly known, is Microsoft’s  first server side scripting engine that enables you to make dynamic and interactive web pages.Classic ASP uses server-side scripting to dynamically produce web pages that are not affected by the type of browser the website visitor is using.The default scripting language used for writing ASP is VBScript, although you can use other scripting languages like JScript (Microsoft’s version of JavaScript).

Classic ASP pages have the extension .asp instead of .htm, when a page with the extension .asp is requested by a browser the web server knows to interpret any ASP contained within the web page before sending the HTML produced to the browser. This way all the ASP is run on the web server and no ASP will ever be passed to the web browser.

– ASP is Interpreted language based on scripting languages like Javascript or VBScript.
– ASP has Mixed HTML and coding logic.
– Limited development and debugging tools available.
– Limited OOPS support.
– Limited session and application state management.
– Poor Error handling system.
– No in-built support for XML.
– No fully distributed data source support.
– ASP does not have the concept of inheritance.
ASP.Net – ASP.NET has better language support, a large set of new controls, XML-based components, and better user authentication.
ASP.NET is a Web application framework developed and marketed by Microsoft to allow programmers to build dynamic Web sites, Web application and Web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft’s Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language.

–  ASP.Net is supported by compiler and has compiled language support.
– Separate code and design logic possible.
– Variety of compilers and tools available including the Visual studio.Net.
– Completely Object Oriented.
– Complete session and application state management.
– Full proof error handling possible.
– Full XML Support for easy data exchange.
– Fully distributed data source support.
– ASP.Net web forms inherit the class written in code behind.
– ASP.NET supports C# (C sharp), VB, and C++.
Features of ASP.Net
– Interoperability
– Because computer systems commonly require interaction between new and older applications, the .NET Framework provides means to access functionality that is implemented in programs that execute outside the .NET environment. Access to COM components is provided in the System Run time. Inter op Services and System.Enterprise Services namespaces of the framework; access to other functionality is provided using the Platform Invocation Services feature.
– Common Language Runtime Engine
– The Common Language Runtime (CLR) is the execution engine of the .NET Framework. All .NET programs execute under the supervision of the CLR, guaranteeing certain properties and behaviors in the areas of memory management, security, and exception handling.
–  Language Independence
–  The .NET Framework introduces a Common Type System, or CTS. The CTS specification defines all possible data types and programming constructs supported by the CLR and how they may or may not interact with each other conforming to the Common Language Infrastructure (CLI) specification. Because of this feature, the .NET Framework supports the exchange of types and object instances between libraries and applications written using any conforming .NET language.
–  Base Class Library
–  The Base Class Library (BCL), part of the Framework Class Library (FCL), is a library of functionality available to all languages using the .NET Framework. The BCL provides classes which encapsulate a number of common functions, including file reading and writing, graphic rendering, database interaction, XML document manipulation and so on.
–  Simplified Deployment
– The .NET Framework includes design features and tools that help manage the installation of computer software to ensure that it does not interfere with previously installed software, and that it conforms to security requirements.
– Security
–  The design is meant to address some of the vulnerabilities, such as buffer overflows, that have been exploited by malicious software. Additionally, .NET provides a common security model for all applications.

Difference between C# and

Difference between C# and
The main difference is C sharp Language is case sensitive while Vb.Net is not case sensitive. 
Variable declaration in C#  – string a, int a
Variable declaration in Vb.Net – Dim a as string