Here is Some codes And Book you Need For codeing In Dot net visual studio using C# If There Is Some better Solution Please Send e-mail me the solution will be Published with your name thanks
Thursday, 23 June 2011
ASP.NET
-::ASP.NET::-
Querry?? What is the process-flow for ASP.Net?
1. User requests an ASPx page in their browser
2. An HTTP requests is sent to IIS
3. The xspisapi.dll isapi filter intercepts the request and passes the request on to the XSP worker process (xspwp.exe)
4. Xspwp takes care of handing the request to the appropriate HTTPModules and finally an HTTPHandler as defined in the configuration files.
5. The ASPX page is read from the HardDisk or cache and server code is loaded into memory and executed.
6. The server side code outputs normal HTML which is handed back through the chain of modules and eventually to IIS, which sends the response back to the client's browser.
7. If the user clicks or otherwise acts on an HTML element (say, a textbox) that has a server side event handler, the form is posted back to the server with hidden form fields containing information as to what control and event occurred. Some controls do not automatically post by default, but wait for a button_click event to post. This is configurable by the developer.
8. The ASPx page is again loaded into memory using the same sequence of events as before, but this time ASP.net reads in the hidden form field data and automagically triggers the appropriate _OnChange, OnClick and other appropriate event handlers.
9. Resulting HTML is sent to the browser
10. The process continues in a continual "Post Back" cycle.
Querry?? What are HTTP Modules?
Definition of HTTP Modules: (ISAPI : Internet Service Application Programming)
HTTP modules are a logical replacement for ISAPI filters. Modules are a class that can participate in every web request. This is appropriate for code that should run on every request, such as caching, authentication or state management
Querry?? What are HTTP Handlers?
HTTP Handlers provide the end point in the processing of a web request and are equivalent to ISAPI Extensions today. For example, many handlers can be involved in the request for an ASPX page, but only 1 handler is invoked. The handler runs after the HTTP modules have run. Which handler is invoked is determined by configuration settings in the config.web file. Handlers are assigned to handle requests based on the extension of the page requested.
Querry?? What an Asp.net Web Application Consists?
A simple ASP.NET Web Application Consists of Four Things.
1.A virtual Directory in IIS , configured as an Application Root, to hold the files that make up the application and to control access to the files.
2. One or more .aspx files.
3. A Global.asax file that is used to provide Application and Session Startup and Cleanup code.
4. A Web.Config file used to store configuration Settings.
Querry?? What Global.asax Contains?
The Global. asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events, session-level events and CustomHttpModules events raised by ASP.NET.Global.asax file resides in the root directory of an ASP.NET based application.
Global. asax is a file used to provide Application and Session Startup and Cleanup code.
The following Tasks can be performed in Global.asax
1.Respond to selected Application and Session Events.
a)Application_OnStart :Event is fired when first Request for any .aspx page is received.
This even is used to
a). Initialize Application Variables.
b).To execute Startup Code.
b)Session_Onstart: Event is fired, When a request comes from a user who does not have a current session in Application Current Session is identified by SessionID cookie..
This even is used to
a). Initialize Session -level Variables.
b).To execute per user Startup Code.
c)Application_BeginRequest
d)Application_EndRequest
e)Session_OnEnd
f)Application_OnEnd
2.Respond to Events of Custom HttpModules you have created for applications.
NB:- HttpModules are Classes that inherit the IHttpModule interface and Participate in Processing ASP.NET Requests.
3.Import Namespaces into the application using @Import Directive.
So without need of Import Namespace in each page and without having to fully qualify the member Names.
NB:- If two or more Namespaces contain same members then must use Fully qualified member names to avoid conflicts.
4.Register Assemblies for use in Your application using @Assembly Directive.
5.Create Instances of application level objects using
Querry?? What is the process-flow for ASP.Net?
1. User requests an ASPx page in their browser
2. An HTTP requests is sent to IIS
3. The xspisapi.dll isapi filter intercepts the request and passes the request on to the XSP worker process (xspwp.exe)
4. Xspwp takes care of handing the request to the appropriate HTTPModules and finally an HTTPHandler as defined in the configuration files.
5. The ASPX page is read from the HardDisk or cache and server code is loaded into memory and executed.
6. The server side code outputs normal HTML which is handed back through the chain of modules and eventually to IIS, which sends the response back to the client's browser.
7. If the user clicks or otherwise acts on an HTML element (say, a textbox) that has a server side event handler, the form is posted back to the server with hidden form fields containing information as to what control and event occurred. Some controls do not automatically post by default, but wait for a button_click event to post. This is configurable by the developer.
8. The ASPx page is again loaded into memory using the same sequence of events as before, but this time ASP.net reads in the hidden form field data and automagically triggers the appropriate _OnChange, OnClick and other appropriate event handlers.
9. Resulting HTML is sent to the browser
10. The process continues in a continual "Post Back" cycle.
Querry?? What are HTTP Modules?
Definition of HTTP Modules: (ISAPI : Internet Service Application Programming)
HTTP modules are a logical replacement for ISAPI filters. Modules are a class that can participate in every web request. This is appropriate for code that should run on every request, such as caching, authentication or state management
Querry?? What are HTTP Handlers?
HTTP Handlers provide the end point in the processing of a web request and are equivalent to ISAPI Extensions today. For example, many handlers can be involved in the request for an ASPX page, but only 1 handler is invoked. The handler runs after the HTTP modules have run. Which handler is invoked is determined by configuration settings in the config.web file. Handlers are assigned to handle requests based on the extension of the page requested.
Querry?? What an Asp.net Web Application Consists?
A simple ASP.NET Web Application Consists of Four Things.
1.A virtual Directory in IIS , configured as an Application Root, to hold the files that make up the application and to control access to the files.
2. One or more .aspx files.
3. A Global.asax file that is used to provide Application and Session Startup and Cleanup code.
4. A Web.Config file used to store configuration Settings.
Querry?? What Global.asax Contains?
The Global. asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events, session-level events and CustomHttpModules events raised by ASP.NET.Global.asax file resides in the root directory of an ASP.NET based application.
Global. asax is a file used to provide Application and Session Startup and Cleanup code.
The following Tasks can be performed in Global.asax
1.Respond to selected Application and Session Events.
a)Application_OnStart :Event is fired when first Request for any .aspx page is received.
This even is used to
a). Initialize Application Variables.
b).To execute Startup Code.
b)Session_Onstart: Event is fired, When a request comes from a user who does not have a current session in Application Current Session is identified by SessionID cookie..
This even is used to
a). Initialize Session -level Variables.
b).To execute per user Startup Code.
c)Application_BeginRequest
d)Application_EndRequest
e)Session_OnEnd
f)Application_OnEnd
2.Respond to Events of Custom HttpModules you have created for applications.
NB:- HttpModules are Classes that inherit the IHttpModule interface and Participate in Processing ASP.NET Requests.
3.Import Namespaces into the application using @Import Directive.
So without need of Import Namespace in each page and without having to fully qualify the member Names.
NB:- If two or more Namespaces contain same members then must use Fully qualified member names to avoid conflicts.
4.Register Assemblies for use in Your application using @Assembly Directive.
5.Create Instances of application level objects using
PAGE
-::PAGE::-
In general, the life cycle for a Web Forms page is similar to that of any Web process that runs on the server. Certain characteristics of Web processing — information passed via HTTP protocol, the stateless nature of Web pages, and so on — apply to Web Forms pages just as they do to most Web applications.
The ASP.NET page framework performs many Web application services for you. For example, the ASP.NET page framework captures information posted with the Web Forms page, extracts the relevant values, and makes the information accessible via object properties.
Querry?? What is RoundTrip?
For Each user action on the form, the form must be posted to the server, processed, and returned to the browser. This sequence of events is referred to as a round trip.
In Web Forms, most user actions — such as clicking a button — result in a round trip.
In any Web scenario, pages are recreated with every round trip.
For that reason, the events available in ASP.NET server controls are usually limited to click-type events.
By the same token, server controls do not expose high-frequency events such as onmouseover, because each time such an event is raised, another round trip to the server would occur, which would considerably affect response time in the form.
Querry?? Why pages are said to be stateless?
The values of a page's variables and controls are not preserved on the server.
In a traditional Web application, the only information that the server has about a form is the information that the user has added to the controls on the form, because that information is sent to the server when the form is posted. Other information, such as variable values and property settings, is discarded.
ASP.NET works around these limitations in the following ways:
• It saves page and control properties between round trips. This is referred to as saving the view state of the control.
• It provides state management facilities so you can save your own variable and application-specific or session-specific information between round trips.
• It can detect when a form is requested for the first time versus when the form is posted, which allows you to program accordingly. You may want a different behavior during a page postback versus an initial request.
Querry?? Benefits of an Event-Driven Model versus a Linear Processing Model
If you have experience using Active Server Pages (ASP), you recognize that ASP is a linear processing model. An ASP page is processed in a top-to-bottom sequence. Each line of ASP code and static HTML is processed in sequence as it appears in the file. User actions cause the page to be posted to the server in a round trip. Since this action causes a round trip, the server must recreate the page. After the page is recreated, it is processed in the same top-to-bottom sequence as before, and therefore the page is not exhibiting truly event-driven behavior. To create an event-driven experience, you need to explicitly design it. In addition, you have to explicitly maintain page and control state at the most basic level. This model limits the richness of the user interfaces that can be assembled, and it increases the complexity of the code needed to support it.
In comparison, an event-driven model, as in a traditional Visual Basic application, contains programmable elements that are initialized and displayed on the form. Users interact with the elements, which cause events to be raised that in turn call event handlers. This model supports true event-driven behavior, which, by design, greatly extends the richness of the user interfaces that can be assembled, and it reduces the complexity of the code needed to support it.
ASP.NET replaces the linear processing model of ASP by emulating the behavior of an event-driven model. The ASP.NET page framework is provided to implicitly make the associations of an event to an event handler for you. Using the page framework allows you to easily create a user interface that reacts to user actions. For details on creating and using events and event handlers, see Server Event Handling in Web Forms Pages.
In addition, this same framework eases the implementation of page and control state management. For more information on state management, see Web Forms State Management.
For example, ASP.NET allows you to set up event handlers in server code for events that are passed from the browser. Assume the user is interacting with a Web Forms page that contains one button server control. The user clicks the button control and an event is raised that is transmitted via an HTTP post to the server where the ASP.NET page framework interprets the posted information and associates the raised event with an appropriate event handler. This event handler can be a default handler supplied by ASP.NET or it can be your custom implementation. The framework automatically calls the appropriate event handler for the button as part of the framework's normal processing. As a result, you no longer need to explicitly design event-like behavior into a linear processing model. For more information on Web Forms event handling, see ASP.NET Server Control Event Model
Querry?? What are the different Stages in Page Processing?
The first time that an ASP.NET Web form page is executed, the code contained within the page(and any code-behind class associated with the page) is compiled into a class that inherits from the Page base class. Once compiled, the class is executed , the resulting HTML is rendered to the browser and the class is removed from memory.
During this the Web Forms Page goes through different stages. They are
1.Init:-Page and Control settings are Initialized as necessary for the request.
2.LoadViewState:-Server control state that was saved to ViewState in an earlier request is restored.
3.LoadPostData:-Any data returned in Server Control form fields is processed and the relevant Control Properties are updated.
4.Load:-Controls are Created and Loaded, and Control state matches the data entered by the client.
5.RaisePostDataChanged Event:-Events are raised in response to changes in control data from previous request to current request.
6.RaisePostBackEvent:-The event that caused the Post Back is handled and the appropriate Server-side events are raised.
7.PreRender:-Any Changes that need to be made prior to Rendering the page are processed. Any Processing after this point will not be rendered to the page.
8.SaveViewState:-Server Control State is Saved back to the Page’s View State prior to tearing down the controls.
9.Render:-Control and Page Output is rendered to the client.
(Dispose Stage:- in which References to Expensive resources such as database connections must be released in this phase. Here Dispose Method is used)
10.Unload:-The Page and its Constituent Controls are removed from memory on the server.
?Of These Stages in which stages we can handle Events?
Of These Stages you can add Page Level Event Handler for Init, Load, Pre Render and Render Stages.
For other Stages such as, LoadViewState, SaveViewState ,LoadPostData ,RaisePostDataChangedEvent,RaisePostBackEvent Stages you can override the appropriate method to customize the processing of these stages.
Querry?? What is PostBack?
Post Back is the process by which a Web Form Page submits an Http Post Request to itself in response to some User action.
Querry?? How do u handle PostBack?
LoadPostData and RaisePostDataChangedEvent are methods of the IPostBackDataHandler interface, and RaisePostBackEvent belongs to the IPostBackEventHandler interface. If your control participates in postback data processing you must implement IPostBackDataHandler. If your control receives postback events you must implement IPostBackEventHandler.
NB:-The CreateChildControls method is not listed in the table because it is called whenever the ASP.NET page framework needs to create the controls tree and this method call is not limited to a specific phase in a control's lifecycle. For example, CreateChildControls can be invoked when loading a page, during data binding, or during rendering.
In general, the life cycle for a Web Forms page is similar to that of any Web process that runs on the server. Certain characteristics of Web processing — information passed via HTTP protocol, the stateless nature of Web pages, and so on — apply to Web Forms pages just as they do to most Web applications.
The ASP.NET page framework performs many Web application services for you. For example, the ASP.NET page framework captures information posted with the Web Forms page, extracts the relevant values, and makes the information accessible via object properties.
Querry?? What is RoundTrip?
For Each user action on the form, the form must be posted to the server, processed, and returned to the browser. This sequence of events is referred to as a round trip.
In Web Forms, most user actions — such as clicking a button — result in a round trip.
In any Web scenario, pages are recreated with every round trip.
For that reason, the events available in ASP.NET server controls are usually limited to click-type events.
By the same token, server controls do not expose high-frequency events such as onmouseover, because each time such an event is raised, another round trip to the server would occur, which would considerably affect response time in the form.
Querry?? Why pages are said to be stateless?
The values of a page's variables and controls are not preserved on the server.
In a traditional Web application, the only information that the server has about a form is the information that the user has added to the controls on the form, because that information is sent to the server when the form is posted. Other information, such as variable values and property settings, is discarded.
ASP.NET works around these limitations in the following ways:
• It saves page and control properties between round trips. This is referred to as saving the view state of the control.
• It provides state management facilities so you can save your own variable and application-specific or session-specific information between round trips.
• It can detect when a form is requested for the first time versus when the form is posted, which allows you to program accordingly. You may want a different behavior during a page postback versus an initial request.
Querry?? Benefits of an Event-Driven Model versus a Linear Processing Model
If you have experience using Active Server Pages (ASP), you recognize that ASP is a linear processing model. An ASP page is processed in a top-to-bottom sequence. Each line of ASP code and static HTML is processed in sequence as it appears in the file. User actions cause the page to be posted to the server in a round trip. Since this action causes a round trip, the server must recreate the page. After the page is recreated, it is processed in the same top-to-bottom sequence as before, and therefore the page is not exhibiting truly event-driven behavior. To create an event-driven experience, you need to explicitly design it. In addition, you have to explicitly maintain page and control state at the most basic level. This model limits the richness of the user interfaces that can be assembled, and it increases the complexity of the code needed to support it.
In comparison, an event-driven model, as in a traditional Visual Basic application, contains programmable elements that are initialized and displayed on the form. Users interact with the elements, which cause events to be raised that in turn call event handlers. This model supports true event-driven behavior, which, by design, greatly extends the richness of the user interfaces that can be assembled, and it reduces the complexity of the code needed to support it.
ASP.NET replaces the linear processing model of ASP by emulating the behavior of an event-driven model. The ASP.NET page framework is provided to implicitly make the associations of an event to an event handler for you. Using the page framework allows you to easily create a user interface that reacts to user actions. For details on creating and using events and event handlers, see Server Event Handling in Web Forms Pages.
In addition, this same framework eases the implementation of page and control state management. For more information on state management, see Web Forms State Management.
For example, ASP.NET allows you to set up event handlers in server code for events that are passed from the browser. Assume the user is interacting with a Web Forms page that contains one button server control. The user clicks the button control and an event is raised that is transmitted via an HTTP post to the server where the ASP.NET page framework interprets the posted information and associates the raised event with an appropriate event handler. This event handler can be a default handler supplied by ASP.NET or it can be your custom implementation. The framework automatically calls the appropriate event handler for the button as part of the framework's normal processing. As a result, you no longer need to explicitly design event-like behavior into a linear processing model. For more information on Web Forms event handling, see ASP.NET Server Control Event Model
Querry?? What are the different Stages in Page Processing?
The first time that an ASP.NET Web form page is executed, the code contained within the page(and any code-behind class associated with the page) is compiled into a class that inherits from the Page base class. Once compiled, the class is executed , the resulting HTML is rendered to the browser and the class is removed from memory.
During this the Web Forms Page goes through different stages. They are
1.Init:-Page and Control settings are Initialized as necessary for the request.
2.LoadViewState:-Server control state that was saved to ViewState in an earlier request is restored.
3.LoadPostData:-Any data returned in Server Control form fields is processed and the relevant Control Properties are updated.
4.Load:-Controls are Created and Loaded, and Control state matches the data entered by the client.
5.RaisePostDataChanged Event:-Events are raised in response to changes in control data from previous request to current request.
6.RaisePostBackEvent:-The event that caused the Post Back is handled and the appropriate Server-side events are raised.
7.PreRender:-Any Changes that need to be made prior to Rendering the page are processed. Any Processing after this point will not be rendered to the page.
8.SaveViewState:-Server Control State is Saved back to the Page’s View State prior to tearing down the controls.
9.Render:-Control and Page Output is rendered to the client.
(Dispose Stage:- in which References to Expensive resources such as database connections must be released in this phase. Here Dispose Method is used)
10.Unload:-The Page and its Constituent Controls are removed from memory on the server.
?Of These Stages in which stages we can handle Events?
Of These Stages you can add Page Level Event Handler for Init, Load, Pre Render and Render Stages.
For other Stages such as, LoadViewState, SaveViewState ,LoadPostData ,RaisePostDataChangedEvent,RaisePostBackEvent Stages you can override the appropriate method to customize the processing of these stages.
Querry?? What is PostBack?
Post Back is the process by which a Web Form Page submits an Http Post Request to itself in response to some User action.
Querry?? How do u handle PostBack?
LoadPostData and RaisePostDataChangedEvent are methods of the IPostBackDataHandler interface, and RaisePostBackEvent belongs to the IPostBackEventHandler interface. If your control participates in postback data processing you must implement IPostBackDataHandler. If your control receives postback events you must implement IPostBackEventHandler.
NB:-The CreateChildControls method is not listed in the table because it is called whenever the ASP.NET page framework needs to create the controls tree and this method call is not limited to a specific phase in a control's lifecycle. For example, CreateChildControls can be invoked when loading a page, during data binding, or during rendering.
-::.NET FRAMEWORK::-
Querry?? What is .NET?(.NET Framework)
.NET is a new Environment for Developing and Running software Applications, featuring ease of Development of Web based Services, rich standard runtime services available to Components written in a variety of Programming Languages and Inter language interoperability.
Querry?? What is .NET Framework?
.NET Framework is a set of Technologies that are designed to transform Internet into a full-scale distributed Computing Platform.
Querry?? What are the new Technologies in .NET Framework? Or
What .NET Framework consists?
.Net Framework Consists of Two main Parts.
a).Common Language Runtime(CLR)
b) .NET Framework Class Library
Querry?? What is CLR?
CLR is a set of Standard Resources responsible for execution of Code developed using .NET Languages.
CLR is a Replacement to win32 API.
Querry?? What CLR do?
CLR take care of
1.Memory Management
2.Thread Execution
3.CodeExecution
4.Code Safety Verification
5.Compilation
6.Automatic Garbage Collection
7.Very High Level Of Security while Executing
It Provides Cross-Language Inheritance and abilty to compile once and run on any CPU and OS that supports runtime through Compilers.
• Memory management. The CLR maintains a managed heap that is used for all memory allocations. The CLR also cleans up objects that are no longer used. Because of the information found in IL and Metadata, the CLR is able to enforce that references always refer to compatible types, null references are never accessed, instances are never referenced after they are freed, etc. This is one very important aspect of code management performed by the Common Language Runtime.
• Security. The CLR makes sure that code can not undermine a system if it is not trusted. An example of un-trusted code would be a binary that was downloaded and executed from a website. The great thing about managed code is that the un-trusted software still runs at full native speed. However, at the point of JIT-compiling, the CLR was able to insert enough code to assure that security cannot be breached. If the executable crosses the line, the CLR knows about it, and will raise a security exception. This will cause the unacceptable operation to fail.
• Thread management. Although you can create your own thread objects with managed code, the CLR maintains a thread pool which can be used by your software. The thread pool efficiently uses threads for asynchronous behavior, and then returns an unused thread to a queue until it is needed again.
• Type safety. It is impossible for managed code to coerce a type into an incompatible type. At runtime the CLR checks all typecasting operations to be sure that the cast is valid. Because managed code uses references to objects in a managed heap (rather than pointers), it is also impossible to coerce one type to another through pointer manipulation. This drastically reduces bugs, and removes the fear that third-party code might undermine the integrity of your system.
• Code verification. The CLR asserts certain truisms about managed code. For example, the CLR (by default) will not JIT compile code that references a variable before it has been assigned to. The CLR can also be made to JIT compile code so that numerical operations that overflow raise exceptions so that they can be caught (although this is not the default). The CLR also asserts that all methods must have a return instruction. It is impossible for one instruction to run-over into the next. Code verification is another feature that makes code robust, and makes it safe to run un-trusted or semi-trusted components.
Querry?? What Compiler do?
The compiler compiles the source code into Intermediate Language (Microsoft Intermediate Language),Which is language Independent. Then it is compiled to native machine code.
Querry?? What is Microsoft Intermediate Language(MSIL)?
MSIL or IL is the CPU Independent Instruction set that is generated by Microsoft .NET Framework Compilers and Consumed by .NET Framework’s Common Language Runtime.
Before MSIL can be executed, it must be converted to native CPU-Specific Code by Common Language Runtime.
IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language).
Querry?? What is the CTS?
CTS = Common Type System. This is the range of types that the .NET runtime understands, and therefore that .NET applications can use. However note that not all .NET languages will support all the types in the CTS. The CTS is a superset of the CLS.
Querry?? What is the CLS?
CLS = Common Language Specification. This is a subset of the CTS, which all .NET languages are expected to support. The idea is that any program, which uses CLS-compliant types, can interoperate with any .NET program written in any language.
In theory this allows very tight interlope between different .NET languages - for example allowing a C# class to inherit from a VB class.
Performing Cross-Language Inheritance the Language Compilers must follow CLS.
CLS(Common Language Specification) describes a subset of Data types supported by Runtime, that are common to all of the languages used in .NET.
Querry?? What are Data Types available in .NET?
Data Type is an attribute that specifies the type of data that object can hold.
System.Boolean ? 1 byte
System.Byte ? 1 byte
System.Char ? 2 bytes
System.Int16 ? 2 bytes
System.Int32 ( 4 bytes
System.Int64 ( 8bytes
System.Object ( 4bytes
System.Single ( 4bytes
System.Double ( 8bytes
System.Decimal ( 12bytes
System.DateTime ( 8bytes
System.String ( 10bytes +(2*string length)
System.ValueType ( Sum of Member sizes(User Defined Type)
Querry?? What is UnManaged Code?
UnManaged Code is code that is executed directly by O.S, outside the Microsoft .NET Framework’s Common Language Runtime. Unmanaged code must provide its own memory management, typechecking and security support, unlike Managed code which receives these services from Common Language Runtime. Unmanaged code must be executed outside the .NET Framework
Querry?? What is Managed Environment?
A Managed Environment is one which the Environment Provides Services such as Garbage Collection, Security and Other Similar Features.
Querry?? What is Managed Code?
.NET Framework Provides Several Core Runtime Services to the Programs that run within it. For eg: Memory Management, Cross-Language Integration, Automatic Lifetime Control of Objects etc.
For these services to work the code must provide a minimum Level of Information to the Runtime. Such a Code is called Managed Code.
All C# and VB.NET code is Managed by Default.
Querry?? What are Managed Classes?
These are Classes that the memory for Instances of the class is Managed by Garbage Collector and the Class becomes a Fully Paid up member of .NET community with the benefits that brings.
Eg: Benefit is proper interop with classes written in Other Languages.
Restriction is that a managed class can inherit from one base class only.
Querry?? What is an Assembly?
An Assembly Consists of one or more files( Dlls, exes, Html files etc) , which represents a group of resources ,Type Definitions and Implementation of those Types.
An Assembly may also contain references to other assemblies.
Querry?? What is Versioning in .NET ?
Each assembly has a four-part version number as a part of its identity. This version number is essential to distinguish different versions of an assembly for the purposes of side-by-side.
The 4 part number will be in the following format.
MajorVersion.MinorVersion.BuildNumber.Revision
Assemblies of either of first two parts different are viewed as ‘Incompatible’.
If First two parts are same , but third is different , the assemblies are referred as ‘may be compatible’.
If only fourth part is different , assemblies are declared as ‘Compatible’
NB:-This version policy can be specified via ‘The Application Configuration File’
Querry?? What is Manifest?
Manifest is the set of Metadata that describes the contents of the assembly and the Metadata also describes the dependencies and Version Information associated with an assembly.
Querry?? What are different types of Assemblies?
There are Two Types of Assemblies. They are Private Assembly and Shared Assembly.
Private Assembly is used by a single application and is stored in Application Directory or a subdirectory beneath.
Shared Assembly is used by Multiple Applications and is Stored in Global Assembly Cache(GAC).Runtime enforces Versioning Constraints on Shared Assemblies only and not on Private Assemblies.
Querry?? What is GAC?
Global Assembly Cache is a repository of assemblies maintained by .NET runtime.
Querry?? How Assebly Dll or exe is checked?
Using ILDASM.EXE Utility.
Querry?? What is reflection?
All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System. Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember), or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).
Querry?? What is .NET Class Library?
.NET Class Library is a collection of reusable types that are tightly integrate with the Common Language Runtime, from which your own Managed Code can derive functionality.
Querry?? Manifest:
It contains assembly name, version number, referenced assemblies, strong name etc
It contains detailed description of the assembly contents. A manifest contains metadata describing the name, resources, types, and version of the assembly as well as dependencies upon other assemblies. The manifest makes an assembly self-describing, easier to deploy, and not bound to a particular system because of storing data in the windows registry.
Manifest mainly contains four parts:
1. Identity: Name of the assembly. That means what’s used to uniquely identify this particular assembly.
2. Strong name: It is a public key which is generated by author of the assembly to shared assembly to identify it uniquely.
3. Version no: This describes the no of the version.
How can a version no. is given to assembly? (Major.Minor.Build.Revision) Eg: 1.6.12.20
4. Referenced assemblies: This is the reference where the information is recorded about the assemblies.
?Types of assemblies:
1. Application _Private assembly: This is being generated for a particular application. We can use this assembly only in that particular application. We can’t share it to other applications
2. Shared assembly: It’ll reside in Global Assembly Cache (GAC), we can use that in any other application.
Path to view shared assemblies: c: windows\ assembly
• ILDASM.EXE ? Used to view the details of a particular assembly.
• SN.EXE? Nothing but strong name indication
• GACUTIL.EXE? By using this command we can install/uninstall the assembly from GAC (Global Assembly Cache)
The procedure to Add The Assembly to the cache:
1) Go to command prompt
2) C:\program files\Microsoft visual studio 8\Uc>cd
3) C:\>sn(space) –k(space).snk?press enter Eg: apl.snk
4) Goto my documents? projects?open the project which u desired?click on solution explorer’s second option (show all files)?click on myproject?select assembly info.vb
5) Create an assemblykey file as Eg: (“apl.snk”) create build.
6) Goto command prompt
7) C:\>gacutil.exe –I (give the path where our appln is resided)
8) Eg: c:\.gasutil.exe –I D:\>winapp\winapp\bin\debug\winapp.exe.
Querry?? What is Application Domain?
Application Domain is a Construct in the CLR that is the unit of isolation for an application.
The Isolation Guarantees the following:
a) An Application Can be Independently stopped.
b) An Application cannot directly access code or resources in another application.
c) A fault in an application cannot affect other applications.
Querry?? What platforms do the .NET Framework run on?
The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development.
Querry?? What is garbage Collection?
Garbage Collection is a system by which Common Language Runtime takes responsibility for managing the lifetime of Objects and heap memory that they occupy.
Garbage collection is an algorithm. It works by periodically running through a list of all the objects that are currently being referenced by an application. All objects that it doesn’t find during this search are ready to be destroyed and the memory reclaimed.
The Implication of this algorithm is that the runtime doesn’t get notified immediately when the final reference on an object goes away-it only finds out during the next sweep of the heap.
For this Microsoft Recommends Dispose() method and Finalize() methods, to get freed object resources.
NB:- System.GC class provides Collect method that uses to collect all un referenced objects immediately.
The syntax implementing the Dispose method of the IDisposable interface and overriding the Finalize method of the Object class is shown with this table:
IL C++/CLI C# VB
Dispose ~ClassName Dispose Dispose
Finalize !ClassName ~ClassName Finalize
Visual Basic does not hide Dispose and Finalize. The automatically created code (with Visual Studio 2005) also includes the Dispose(bool) pattern.
class Resource : IDisposable
{
private bool disposed = false;
~Resource()
{
Dispose(false);
}
protected void Dispose(bool disposing)
{
if (disposing)
{
// dispose managed resources
}
// dispose unmanaged resources
disposed = true;
}
#region IDisposable Members
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
Querry?? What is .NET?(.NET Framework)
.NET is a new Environment for Developing and Running software Applications, featuring ease of Development of Web based Services, rich standard runtime services available to Components written in a variety of Programming Languages and Inter language interoperability.
Querry?? What is .NET Framework?
.NET Framework is a set of Technologies that are designed to transform Internet into a full-scale distributed Computing Platform.
Querry?? What are the new Technologies in .NET Framework? Or
What .NET Framework consists?
.Net Framework Consists of Two main Parts.
a).Common Language Runtime(CLR)
b) .NET Framework Class Library
Querry?? What is CLR?
CLR is a set of Standard Resources responsible for execution of Code developed using .NET Languages.
CLR is a Replacement to win32 API.
Querry?? What CLR do?
CLR take care of
1.Memory Management
2.Thread Execution
3.CodeExecution
4.Code Safety Verification
5.Compilation
6.Automatic Garbage Collection
7.Very High Level Of Security while Executing
It Provides Cross-Language Inheritance and abilty to compile once and run on any CPU and OS that supports runtime through Compilers.
• Memory management. The CLR maintains a managed heap that is used for all memory allocations. The CLR also cleans up objects that are no longer used. Because of the information found in IL and Metadata, the CLR is able to enforce that references always refer to compatible types, null references are never accessed, instances are never referenced after they are freed, etc. This is one very important aspect of code management performed by the Common Language Runtime.
• Security. The CLR makes sure that code can not undermine a system if it is not trusted. An example of un-trusted code would be a binary that was downloaded and executed from a website. The great thing about managed code is that the un-trusted software still runs at full native speed. However, at the point of JIT-compiling, the CLR was able to insert enough code to assure that security cannot be breached. If the executable crosses the line, the CLR knows about it, and will raise a security exception. This will cause the unacceptable operation to fail.
• Thread management. Although you can create your own thread objects with managed code, the CLR maintains a thread pool which can be used by your software. The thread pool efficiently uses threads for asynchronous behavior, and then returns an unused thread to a queue until it is needed again.
• Type safety. It is impossible for managed code to coerce a type into an incompatible type. At runtime the CLR checks all typecasting operations to be sure that the cast is valid. Because managed code uses references to objects in a managed heap (rather than pointers), it is also impossible to coerce one type to another through pointer manipulation. This drastically reduces bugs, and removes the fear that third-party code might undermine the integrity of your system.
• Code verification. The CLR asserts certain truisms about managed code. For example, the CLR (by default) will not JIT compile code that references a variable before it has been assigned to. The CLR can also be made to JIT compile code so that numerical operations that overflow raise exceptions so that they can be caught (although this is not the default). The CLR also asserts that all methods must have a return instruction. It is impossible for one instruction to run-over into the next. Code verification is another feature that makes code robust, and makes it safe to run un-trusted or semi-trusted components.
Querry?? What Compiler do?
The compiler compiles the source code into Intermediate Language (Microsoft Intermediate Language),Which is language Independent. Then it is compiled to native machine code.
Querry?? What is Microsoft Intermediate Language(MSIL)?
MSIL or IL is the CPU Independent Instruction set that is generated by Microsoft .NET Framework Compilers and Consumed by .NET Framework’s Common Language Runtime.
Before MSIL can be executed, it must be converted to native CPU-Specific Code by Common Language Runtime.
IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language).
Querry?? What is the CTS?
CTS = Common Type System. This is the range of types that the .NET runtime understands, and therefore that .NET applications can use. However note that not all .NET languages will support all the types in the CTS. The CTS is a superset of the CLS.
Querry?? What is the CLS?
CLS = Common Language Specification. This is a subset of the CTS, which all .NET languages are expected to support. The idea is that any program, which uses CLS-compliant types, can interoperate with any .NET program written in any language.
In theory this allows very tight interlope between different .NET languages - for example allowing a C# class to inherit from a VB class.
Performing Cross-Language Inheritance the Language Compilers must follow CLS.
CLS(Common Language Specification) describes a subset of Data types supported by Runtime, that are common to all of the languages used in .NET.
Querry?? What are Data Types available in .NET?
Data Type is an attribute that specifies the type of data that object can hold.
System.Boolean ? 1 byte
System.Byte ? 1 byte
System.Char ? 2 bytes
System.Int16 ? 2 bytes
System.Int32 ( 4 bytes
System.Int64 ( 8bytes
System.Object ( 4bytes
System.Single ( 4bytes
System.Double ( 8bytes
System.Decimal ( 12bytes
System.DateTime ( 8bytes
System.String ( 10bytes +(2*string length)
System.ValueType ( Sum of Member sizes(User Defined Type)
Querry?? What is UnManaged Code?
UnManaged Code is code that is executed directly by O.S, outside the Microsoft .NET Framework’s Common Language Runtime. Unmanaged code must provide its own memory management, typechecking and security support, unlike Managed code which receives these services from Common Language Runtime. Unmanaged code must be executed outside the .NET Framework
Querry?? What is Managed Environment?
A Managed Environment is one which the Environment Provides Services such as Garbage Collection, Security and Other Similar Features.
Querry?? What is Managed Code?
.NET Framework Provides Several Core Runtime Services to the Programs that run within it. For eg: Memory Management, Cross-Language Integration, Automatic Lifetime Control of Objects etc.
For these services to work the code must provide a minimum Level of Information to the Runtime. Such a Code is called Managed Code.
All C# and VB.NET code is Managed by Default.
Querry?? What are Managed Classes?
These are Classes that the memory for Instances of the class is Managed by Garbage Collector and the Class becomes a Fully Paid up member of .NET community with the benefits that brings.
Eg: Benefit is proper interop with classes written in Other Languages.
Restriction is that a managed class can inherit from one base class only.
Querry?? What is an Assembly?
An Assembly Consists of one or more files( Dlls, exes, Html files etc) , which represents a group of resources ,Type Definitions and Implementation of those Types.
An Assembly may also contain references to other assemblies.
Querry?? What is Versioning in .NET ?
Each assembly has a four-part version number as a part of its identity. This version number is essential to distinguish different versions of an assembly for the purposes of side-by-side.
The 4 part number will be in the following format.
MajorVersion.MinorVersion.BuildNumber.Revision
Assemblies of either of first two parts different are viewed as ‘Incompatible’.
If First two parts are same , but third is different , the assemblies are referred as ‘may be compatible’.
If only fourth part is different , assemblies are declared as ‘Compatible’
NB:-This version policy can be specified via ‘The Application Configuration File’
Querry?? What is Manifest?
Manifest is the set of Metadata that describes the contents of the assembly and the Metadata also describes the dependencies and Version Information associated with an assembly.
Querry?? What are different types of Assemblies?
There are Two Types of Assemblies. They are Private Assembly and Shared Assembly.
Private Assembly is used by a single application and is stored in Application Directory or a subdirectory beneath.
Shared Assembly is used by Multiple Applications and is Stored in Global Assembly Cache(GAC).Runtime enforces Versioning Constraints on Shared Assemblies only and not on Private Assemblies.
Querry?? What is GAC?
Global Assembly Cache is a repository of assemblies maintained by .NET runtime.
Querry?? How Assebly Dll or exe is checked?
Using ILDASM.EXE Utility.
Querry?? What is reflection?
All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System. Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember), or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).
Querry?? What is .NET Class Library?
.NET Class Library is a collection of reusable types that are tightly integrate with the Common Language Runtime, from which your own Managed Code can derive functionality.
Querry?? Manifest:
It contains assembly name, version number, referenced assemblies, strong name etc
It contains detailed description of the assembly contents. A manifest contains metadata describing the name, resources, types, and version of the assembly as well as dependencies upon other assemblies. The manifest makes an assembly self-describing, easier to deploy, and not bound to a particular system because of storing data in the windows registry.
Manifest mainly contains four parts:
1. Identity: Name of the assembly. That means what’s used to uniquely identify this particular assembly.
2. Strong name: It is a public key which is generated by author of the assembly to shared assembly to identify it uniquely.
3. Version no: This describes the no of the version.
How can a version no. is given to assembly? (Major.Minor.Build.Revision) Eg: 1.6.12.20
4. Referenced assemblies: This is the reference where the information is recorded about the assemblies.
?Types of assemblies:
1. Application _Private assembly: This is being generated for a particular application. We can use this assembly only in that particular application. We can’t share it to other applications
2. Shared assembly: It’ll reside in Global Assembly Cache (GAC), we can use that in any other application.
Path to view shared assemblies: c: windows\ assembly
• ILDASM.EXE ? Used to view the details of a particular assembly.
• SN.EXE? Nothing but strong name indication
• GACUTIL.EXE? By using this command we can install/uninstall the assembly from GAC (Global Assembly Cache)
The procedure to Add The Assembly to the cache:
1) Go to command prompt
2) C:\program files\Microsoft visual studio 8\Uc>cd
3) C:\>sn(space) –k(space).snk?press enter Eg: apl.snk
4) Goto my documents? projects?open the project which u desired?click on solution explorer’s second option (show all files)?click on myproject?select assembly info.vb
5) Create an assemblykey file as Eg: (“apl.snk”) create build.
6) Goto command prompt
7) C:\>gacutil.exe –I (give the path where our appln is resided)
8) Eg: c:\.gasutil.exe –I D:\>winapp\winapp\bin\debug\winapp.exe.
Querry?? What is Application Domain?
Application Domain is a Construct in the CLR that is the unit of isolation for an application.
The Isolation Guarantees the following:
a) An Application Can be Independently stopped.
b) An Application cannot directly access code or resources in another application.
c) A fault in an application cannot affect other applications.
Querry?? What platforms do the .NET Framework run on?
The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development.
Querry?? What is garbage Collection?
Garbage Collection is a system by which Common Language Runtime takes responsibility for managing the lifetime of Objects and heap memory that they occupy.
Garbage collection is an algorithm. It works by periodically running through a list of all the objects that are currently being referenced by an application. All objects that it doesn’t find during this search are ready to be destroyed and the memory reclaimed.
The Implication of this algorithm is that the runtime doesn’t get notified immediately when the final reference on an object goes away-it only finds out during the next sweep of the heap.
For this Microsoft Recommends Dispose() method and Finalize() methods, to get freed object resources.
NB:- System.GC class provides Collect method that uses to collect all un referenced objects immediately.
The syntax implementing the Dispose method of the IDisposable interface and overriding the Finalize method of the Object class is shown with this table:
IL C++/CLI C# VB
Dispose ~ClassName Dispose Dispose
Finalize !ClassName ~ClassName Finalize
Visual Basic does not hide Dispose and Finalize. The automatically created code (with Visual Studio 2005) also includes the Dispose(bool) pattern.
class Resource : IDisposable
{
private bool disposed = false;
~Resource()
{
Dispose(false);
}
protected void Dispose(bool disposing)
{
if (disposing)
{
// dispose managed resources
}
// dispose unmanaged resources
disposed = true;
}
#region IDisposable Members
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
OBJECT ORIENTED CONCEPTS
-::OBJECT ORIENTED CONCEPTS::-
Querry?? What is Object Oriented Programming?
Object Oriented Programming is an approach that Provides a way of Modularizing programs by creating Partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on Demand.
Querry?? What are the features of Object Oriented Programming?
1.Emphasis is on Data Rather than Procedure.
2.Data is hidden and can’t be accessed by external functions.
3.Programs are divided into what are known as Objects.
4.Objects may communicate with each other through methods.
Querry?? What are the Benefits of Object Oriented Programming?
1.Through Inheritance, we can eliminate redundant code and extend the use of existing classes.
2.We can build programs from the standard Working modules, rather than writing the code from scratch. This leads to savings of Development time and gives Higher productivity.
3.The principle of Data hiding helps from invades by code in other parts of the program.
4.Easy to partition work in a project based on Objects.
5.Object Oriented systems can be easily updated from small to large Systems.
6.Software Complexity can be easily managed.
Querry?? What are the Basic Concepts of Object Oriented Programming?
Basic Concepts of OOPs are
1.DataAbstraction and Encapsulation.
2.Inheritence
3.Polymorphism.
Querry?? What is Data Encapsulation?
The wrapping up of data and methods into a single unit is called Encapsulation.
So data is not accessible to outside world and only those methods can access it.
This insulation of data from direct access by programs is called Data Hiding.
Querry?? What is Inheritance?
Inheritance is the process by which Objects of one class acquire properties of another class. Inheritance Provides the idea of Reusability.
Querry?? What are different types of Inheritance?
1.Single Inheritance:- Only One Base class and One derived Class
2.Multiple Inheritance:- Several Base Classes and a single Derived class
But this possible only with Interfaces and not with Base classes as a class can atmost t extend a base class but can Implements more than one interfaces.
3.Hierarchical Inheritance:-One Base Class and many derived classes.
4.Multilevel Inheritance:-Derived from derived class.
Querry?? What is Polymorphism?
Polymorphism means the ability to take more than one form.
Polymorphism Plays an Important role in allowing Objects having different internal Structures to share the same external interface.
The benefit of Polymorphism is when the appropriate implementation is invoked automatically at runtime depending on the type of Object.
Querry?? What are different types of Polymorphisms that are available?
Operation Polymorphism or Compile Polymorphism(EarlyBinding/StaticBinding/StaticLinking)-Using OverLoaded Methods-The Compiler is able to select and bind the appropriate method to the object for a Particular call at Compiletime Itself.
Eg. Class Dog{}
Class Cat{}
Class Operation{
static void Call(Dog d){}
static void Call(Cat c){} }
Public static void Main(){
Dog d=new Dog();
Cat c=new Cat();
Call(d);
Call(c);
}
And Inclusion Polymorphism or Runtime Polymorphism(LateBinding)-Using Virtual Methods –The decision of which method to call is delayed until Runtime.
Class Maruthi{public virtual void Display(){}}
Class Esteem:Maruthi{public override void Display(){}}
Class Zen:Maruthi{public override void Display(){}}
Class Inclusion{
Public static void Main(){
Maruthi m=new Maruthi();
m=new Esteem();
m.Display();
m=new Zen();
m.Display();
}
Querry?? What are different types of Polymorphisms that are available
?
Runtime Polymorphism and Compile Polymorphism
Querry?? What is Class?
Class is a template of class.
Querry?? What is Object?
Object is an instance of a class.
Querry?? What is Interface?
Like class Interface contains, properties, methods, but interfaces doesn’t contain implementation of those methods.
Interface defines only Abstract Methods and Final fields.
An Interface represents a contract and a class that implements an Interface must implement every aspect of that interface exactly as it is defined.
An Interface is implemented and not extended.
1.A class can implement multiple interfaces.
2.An Interface can’t contain data declarations but you can declare properties.
3.All method declarations in an Interface are Public.
4.There can be no implementation in an Interface.
5.A class implementing the interface must provide implementation code.
6.An Interface can be derived from another Interface.
Querry?? What is an Abstract Class?
An Abstract class is a class that contains methods that have no implementation(i.e abstract methods).
An abstract method is simply a shell or place-marker for a method that will be defined later in a derived class.
The intention of abstract methods is to force every derivation of the class to implement those methods. If a derived class does not implement an abstract method , then that class must also be declared as abstract.
An Abstract class is the class that can’t be instantiated(i.e no direct instances), but must be inherited from. (but whose descendents may have direct instances)
An Abstract class is usually partially implemented or not implemented at all, there by encapsulating common functionality for inherited classes.
NB:-Derived class is also called Concrete class. And Implementation of Abstract class is optional, unlike interface.
MustInherit-Class/MustOverridable-Method-vb.net
Abstract(Class&Method) –C#
Querry?? Differences between an Abstract Class and Interface?
Abstract Class Interface
1.May or maynot have abstract
methods. use virtual attribute in class to implement Partial Implementation. 1.Can only have abstract methods, but abstract Key word is not allowed.
2.Methods can have access modifiers.(except Private Members.) 2.no access modifiers are allowed, implicitly Public..`
3.can have fields, Properties and Methods. 3.can have only final constants, Properties and
Methods.
4.Can Extend a single class and implement one
or more Interfaces. 4.Can’t Extend a Class and can extend a single or multiple interfaces.
*5.Abstract classes form part of the
Inheritance schema. 5.Interfaces do not .we can use same interface in two projects that are not related interms of Inheritance.
6.Can Have Constructor. 6.Can’t Have Constructor.
*7.Its Speed and Fast at Execution. 7.Slow at Execution.
*8.If you are Designing Large Functional units
use an Abstract Class. 8.If you are designing small,Consise bits of Functionality use Interfaces.
*9.If you want provide Common, Implemented functionality among all implementations of
your Component, use an Abstract Class. 9.If the Functionality you are creating will be useful across a wide range of Disperate objects,use an Interface.
Querry?? What are Delegates?
Delegate is a Type defining a method signature, so that delegate instances can hold and Invoke method or list of methods that match its signature.
Delegates Provides Callback behavior in an jectOrientedType Safe Manner.A delegate is a type safe reference to a function or method.
It is useful when you want to register a callback function that gets called when the user selects a menu or when an un handled exception is thrown or you may want a function to be called when an asynchronous operation completes its execution.
Using of Delegate Invoke 4 steps as follows.
a)Delegate Declaration:-modifier delegate return_type delegate_name(parameters)Modifier -?new/static/override/abstract/sealed
eg. delegate void Mathop(double a, double b)
b)Delagate Method Defination:-
public static double Multiply(double a,double b)
{ return (a*b);}
public double Divide(double a,double b)
{return (a/b);}
c)Delegate Instantiation:-
new delegate_type(expression)
Mathop m=new Mathop(multiply);
d)Delegate Invocation:-
delegate_object(paramers list)
double d=Mathop(12.23,34.44);
Querry?? What is Event - Delegate?
An event is a Delegate type class member that is used by the Object or class to provide a notification to other objects that an event has occurred.
Modifier event type event_name
Modifier -?new/static/override/abstract/sealed
Public event Eventhandler click;---here type eventhandler is the delegate type.
When button is clicked the following code will be added in Initailized Component.
This.Button1.Click+=new System.EventHandler(this.Button1_Click)
The event keyword lets you specify a delegate that will be called upon the occurrence of some "event" in your code. The delegate can have one or more associated methods that will be called when your code indicates that the event has occurred. An event in one program can be made available to other programs that target the .NET Framework Common Language Runtime.
Querry?? What is new Modifier?
New modifier is used to hide the base class method from derived class method. It allows to reDefine some methods contained in Derived class.
Querry?? What is Enum?
Enums specify a group of named numeric Constants.
An Enum can be of Type byte, short, int or long.
Public enum Direction: byte{Northe=1,Easr=2,West=4,South=8}Querry?? What is Structure?
Structures can be think as Light weight, memory efficient Classes.
Structure is a User defined Structure, similar to Class. It’s a Class of Value Type. It can have one or more Attributes, of any of other Datatypes.It can also have methods. A Struct object is created using new Keyword, just like a Class.
Querry?? What is the difference between a Struct and a Class?
• The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects, you will allocate additional memory for referencing each object. In this case, the struct is less expensive.
• When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized.
• It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values.
• It is an error to initialize an instance field in a struct.
• There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.
A struct is a value type, while a class is a reference type.
Querry?? What is Shadowing?
Shadowed members are used to create the Local version of members that have broader scope.
Shadowing is used when two programmers come up with same method in the same class , one of the methods get shadowed by scope or inheritance.
Querry?? What is Virtual method?
The Concept of Virtual method is such that the bottom-most implementation of the method is always used in favor of the Parent implementation-regardless of the data type of variable being used in the client code.
Virtual method has an implementation and Provide the derived class with the option of overriding it. The class which contains Virtual methods is known as Virtual Class.
Override modifier is used while overriding an Virtual method.
Querry?? What are Constructors?
Constructors are Procedures that control Initialization of new instances of a class.
Querry?? What are Destructors?
Destructors are Procedures that are used to free System Resources when a class leaves a scope or is set to nothing.
VB.NET—Finalizer;C#- Destructor
Querry?? What are References?
References allows you to use objects defined in Other Assemblies.
Querry?? What are Shared Members (VB)/Static Members(C#)?
Shared Members are Properties, Methods and Fields that are shared by all instances of the class.
Sharing single instance of a data member or function among all instances of a class is useful in applications that use Inheritance.
Querry?? What is Namespace?
Namespaces prevent naming conflicts by organizing classes, Interfaces and Methods into hierarchies.
An assembly can contain one ore more namespaces.
?Anyalternativeto avoid name collisions other then Namespaces.
A scenario that two namespaces named N1 and N2 are there both having the same class say A. now in another class i ve written
using1;
usingN2;
and i am instantiating class A in this class. Then how will u avoid name collisions?
Ans:usingalias
Eg: using MyAlias = MyCompany.Proj.Nested;
Querry?? What are attributes?
Attributes enable you to provide additional Information about Program elements.
Eg. Access Modifiers .these can be used on class and members in the class like variable,property,methods.
Method signature:
Attributes(opt) method_modifier(opt) return_type member_name(parameter_list opt)
1.Public:-Entries that are declared as Public, have public access. There is no Restriction on the accessibility of Public Entries.
2.Protected:- Entries that are declared as Protected, have protected access. They are accessible only from their own classes or from a Derived class.
3.Friend(Internal):- Entries that are declared as Friend, have friend access. They can be accessible from within the program that contains the Declaration and within the Assembly.
4.Private:- Entries that are declared as private, have private access. They can be accessible only within the Class.
5.Protected Friend/Protected Internal:- Entries that are declared as Protected Friend, have Protected Friend. They can be accessible from within the program that contains the Declaration and within the Assembly and in the Derived Classes also.
Querry?? What are Me/MyBase/MyClass keywords?
Me keyword is used any time we want to refer to methods within the Current Object.
(this in C#)
Mybase keyword is used to call Parent Class method within the Subclass.
MyClass is used in a scenario , where the code Calls your own implementation of the method instead of an overridden method in the derived class
Querry?? What is Over Loading?
Over Loading is the ability to define Properties, Methods that have the same name but use different type of data types and different type of Parameters.
Overloading Procedures allow you to provide as many implementations as necessary to handle different kinds of data while giving the appearance of a single Versatile procedure.
Functions of Same name but with different Parameters.
Simply by Changing return type we can’t Overload a method.
Overloads---Keyword-VB
NoKeyword-C#
Querry?? What is Overriding?
Overriding is Defining a method in Derived class that has the same name ,same arguments and same return type as a method in Base Class.
Overridable/Overrides/NotOverridable(sealed)/MustOverride(abstract)---vb
Virtual/Override---C#
Querry?? What is Distributed Computing?
It is a Programming Model in which processing occurs in Many Different Places around the network eg. On a server, Personal Computer ,Hand held device.
This is contrast to the two node system prevalent today(The client and Centralized server).
Querry?? Which namespace is the base class for .net Class library?
system.object
Querry?? using directive vs using statement?
You create an instance in a using statement to ensure that Dispose is called on the object when the using statement is exited. A using statement can be exited either when the end of the using statement is reached or if, for example, an exception is thrown and control leaves the statement block before the end of the statement.
The using directive has two uses:
• Create an alias for a namespace (a using alias).
• Permit the use of types in a namespace, such that, you do not have to qualify the use of a type in that namespace (a using directive).
Querry?? What is the difference between CONST and READONLY?
Both are meant for constant values. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used.
readonly int b;
public X()
{
b=1;
}
public X(string s)
{
b=5;
}
public X(string s, int i)
{
b=i;
}
Also, while a const field is a compile-time constant, the readonly field can be used for runtime constants, as in the following example:
public static readonly uint l1 = (uint) DateTime.Now.Ticks; (this can't be possible with const)
Querry?? What is the difference between ref & out parameters?
An argument passed to a ref parameter must first be initialized. Compare this to an out parameter, whose argument does not have to be explicitly initialized before being passed to an out parameter.
Querry?? What is the difference between Array and Arraylist?
As elements are added to an ArrayList, the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling TrimToSize or by setting the Capacity property explicitly.
Querry?? What is Jagged Arrays?
A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array-of-arrays."
Querry?? What are indexers?
Indexers are Location indicators and are used to access class objects, just like elements in an array. They are useful in cases where a class is a container for other objects.
An Indexer looks like a Property with two following differences.
1.Indexer takes an Index argument and looks like an Array.
2.Indexer is declared using the name this.
Indexers are similar to properties, except that the get and set accessors of indexers take parameters, while property accessors do not.
Public double this [int idx]{get{}set{}}
Eg.class List{ArrayList array=new ArrayList();
Public object this[int index]
{get{return(array[index])}}
set{array[index]=value;}}}
class IndexerTest{public static void main()
{List list=new List();list[0]=”123”;list[1]=”abc”;
for(int I=0;I
Console.writeline(list[I])}}
Querry?? What are indexers?
Indexers are Location indicators and are used to access class objects, just like elements in an array. They are useful in cases where a class is a container for other objects.
An Indexer looks like a Property with two following differences.
1.Indexer takes an Index argument and looks like an Array.
2.Indexer is declared using the name this.
Indexers are similar to properties, except that the get and set accessors of indexers take parameters, while property accessors do not.
Public double this [int idx]{get{}set{}}
Eg.class List{ArrayList array=new ArrayList();
Public object this[int index]
{get{return(array[index])}}
set{array[index]=value;}}}
class IndexerTest{public static void main()
{List list=new List();list[0]=”123”;list[1]=”abc”;
for(int I=0;I
Console.writeline(list[I])}}
Querry?? What are Different DataTypes available in .NET?
1.In Value Type, the variable stores the Data directly in the Stack Memory. i.e Structures,Enumerations.
2.In Reference Type,the Variable stores the Address of the Data and the Data is Stored in the Heap Memory. and Garbage collector take care of freeing of memory resources.
i.e Class,Arrays,Interfaces,Delegate.
Querry?? What are Data Types available in .NET?
Data Type is an attribute that specifies the type of data that object can hold.
System.Boolean ( 1 byte
System.Byte ( 1 byte
System.Char ( 2 bytes
System.Int16 ( 2 bytes
System.Int32 ( 4 bytes
System.Int64 ( 8bytes
System.Object ( 4bytes
System.Single ( 4bytes
System.Double ( 8bytes
System.Decimal ( 12bytes
System.DateTime ( 8bytes
System.String ( 10bytes +(2*string length)
System.ValueType ( Sum of Member sizes(User Defined Type)
?Value type & reference types difference? Example from .NET. Integer & struct are value types or reference types in .NET?
Most programming languages provide built-in data types, such as integers and floating-point numbers, that are copied when they are passed as arguments (that is, they are passed by value). In the .NET Framework, these are called value types. The runtime supports two kinds of value types:
• Built-in value types
The .NET Framework defines built-in value types, such as System.Int32 and System.Boolean, which correspond and are identical to primitive data types used by programming languages.
• User-defined value types
Your language will provide ways to define your own value types, which derive from System.ValueType. If you want to define a type representing a value that is small, such as a complex number (using two floating-point numbers), you might choose to define it as a value type because you can pass the value type efficiently by value. If the type you are defining would be more efficiently passed by reference, you should define it as a class instead.
Variables of reference types, referred to as objects, store references to the actual data. This following are the reference types:
• class
• interface
• delegate
This following are the built-in reference types:
• object
• string
Querry?? What is Boxing and Unboxing?
Boxing is a mechanism of converting a value type to reference type.
Un Boxing is a mechanism of Converting reference type to value type.
Querry?? What are Different Object types offered by CLR?
There are two types of Object types that are offered by CLR. They are
a) Value Types
b) Reference Types
Reference Types are always allocated from the managed heap and the new operator returns the memory address of object and Garbage collector take care of freeing of memory resources.
Eg: Strings,objects etc
Value Types are allocated on a thread’s stack and variable representing the object does not contain a pointer to an object. Value types are lightweight than reference types because they are not allocated in managed heap, not garbage collected and not referenced to by pointers. Value type is referred as structure. value type is primitive type and type does not inherit from another type.
Eg: int32,Boolean,decimal etc.
NB:-Heap is Temporary Memory i.e RAM and Stack is Permanent Memory i.e HardDisk.
Querry?? What are Custom Attributes?
Custom Attributes are used to adorn type,methods,fields etc.
When compiled the compiler emits these method attributes into the managed module’s metadata. At runtime, this metadata can be examined and based on the presence of these attributes the behaviour of the application changes.
Querry?? What is Custom attribute? How to create? If I'm having custom attribute in an assembly, how to say that name in the code?
A: The primary steps to properly design custom attribute classes are as follows:
o. Applying the AttributeUsageAttribute ([AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)])
p. Declaring the attribute. (class public class MyAttribute : System.Attribute { // . . . })
q. Declaring constructors (public MyAttribute(bool myvalue) { this.myvalue = myvalue; })
r. Declaring properties
public bool MyProperty
{
get {return this.myvalue;}
set {this.myvalue = value;}
}
The following example demonstrates the basic way of using reflection to get access to custom attributes.
class MainClass
{
public static void Main()
{
System.Reflection.MemberInfo info = typeof(MyClass);
object[] attributes = info.GetCustomAttributes();
for (int i = 0; i < attributes.Length; i ++)
{
System.Console.WriteLine(attributes[i]);
}
}
}
Querry?? What are Attributes? What are different types of Attributes?
Attributes are used to adorn type,methods,fields etc.
There are at least two types of .NET Attributes. They are
a) Metadata Attributes:-It allows some data to attached to a class or method. This data becomes part of metadata for the class and can be accessed via reflection. Eg [serializable]
NB:-System.Attribute class
b) Context Attributes:-This also uses same syntax as Metadata Attributes but they are fundamentally different. Context Attributes provide an interception mechanism whereby instance activation and method calls can be pre and /or post processed.
Querry?? What is early binding and late binding?
Early binding means that the compiler has knowledge about an object at compile time
? Late binding means that compiler do not have any knowledge about an object
Late Binding uses Create Object to create and instance of the application object, which you can then control.
Eg: Dim oXL as Object
Set oXL=CreateObject(“Excel.Application”)
NB: -Regardless of whether you are using early or late binding use GetObject to manipulate an existing object.
To use Early binding you need to set a reference in your project to the application you want to manipulate.
Eg. Dim oXL as Object
Set oXL=New Excel.Application
Querry?? What are the advantages of early binding and late binding?
Advantages of Early Binding: -
1.Code will run considerably faster, because it can all be compiled up front, but in late binding the code is compiled as it runs.
2.As code is compiled up front, debugging is far easier and compiler will able to spot syntax errors which would have been missed had you used late binding.
3.We can have full access to Intellisense in the project.
4.We can access the application’s built-in constants.
Eg. .windowState=wdWindowStateMaximize
In LateBinding, we use it like the following
.windowState=1
Advantages of Late Binding:-
1.The main Advantage to use late binding is that the code is more certain to be version –Independent.
2.In Early binding, the more references your project contains , the larger the file size and the longer it takes to compile.
3.Some Programming environments don’t allow you to create references to another application.
?In which cases you use override and new base?
Use the new modifier to explicitly hide a member inherited from a base class. To hide an inherited member, declare it in the derived class using the same name, and modify it with the new modifier.
Querry?? What are Sealed Classes in C#?
The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class of another class. (A sealed class cannot also be an abstract class)
Querry?? In which Scenario you will go for Interface or Abstract Class?
Interfaces vs. Abstract Classes
Feature Interface Abstract class
Multiple inheritance A class may implement several interfaces. A class may extend only one abstract class.
Default implementation An interface cannot provide any code at all, much less default code. An abstract class can provide complete code, default code, and/or just stubs that have to be overridden.
Constants Static final constants only, can use them without qualification in classes that implement the interface. On the other paw, these unqualified names pollute the namespace. You can use them and it is not obvious where they are coming from since the qualification is optional. Both instance and static constants are possible. Both static and instance intialiser code are also possible to compute the constants.
Third party convenience An interface implementation may be added to any existing third party class. A third party class must be rewritten to extend only from the abstract class.
is-a vs -able or can-do Interfaces are often used to describe the peripheral abilities of a class, not its central identity, e.g. an Automobile class might implement the Recyclable interface, which could apply to many otherwise totally unrelated objects. An abstract class defines the core identity of its descendants. If you defined a Dog abstract class then Damamation descendants are Dogs, they are not merely dogable. Implemented interfaces enumerate the general things a class can do, not the things a class is.
Plug-in You can write a new replacement module for an interface that contains not one stick of code in common with the existing implementations. When you implement the interface, you start from scratch without any default implementation. You have to obtain your tools from other classes; nothing comes with the interface other than a few constants. This gives you freedom to implement a radically different internal design. You must use the abstract class as-is for the code base, with all its attendant baggage, good or bad. The abstract class author has imposed structure on you. Depending on the cleverness of the author of the abstract class, this may be good or bad. Another issue that's important is what I call "heterogeneous vs. homogeneous." If implementors/subclasses are homogeneous, tend towards an abstract base class. If they are heterogeneous, use an interface. (Now all I have to do is come up with a good definition of hetero/homogeneous in this context.) If the various objects are all of-a-kind, and share a common state and behavior, then tend towards a common base class. If all they share is a set of method signatures, then tend towards an interface.
Homogeneity If all the various implementations share is the method signatures, then an interface works best. If the various implementations are all of a kind and share a common status and behavior, usually an abstract class works best.
Maintenance If your client code talks only in terms of an interface, you can easily change the concrete implementation behind it, using a factory method. Just like an interface, if your client code talks only in terms of an abstract class, you can easily change the concrete implementation behind it, using a factory method.
Speed Slow, requires extra indirection to find the corresponding method in the actual class. Modern JVMs are discovering ways to reduce this speed penalty. Fast
Terseness The constant declarations in an interface are all presumed public static final, so you may leave that part out. You can't call any methods to compute the initial values of your constants. You need not declare individual methods of an interface abstract. They are all presumed so. You can put shared code into an abstract class, where you cannot into an interface. If interfaces want to share code, you will have to write other bubblegum to arrange that. You may use methods to compute the initial values of your constants and variables, both instance and static. You must declare all the individual methods of an abstract class abstract.
Adding functionality If you add a new method to an interface, you must track down all implementations of that interface in the universe and provide them with a concrete implementation of that method. If you add a new method to an abstract class, you have the option of providing a default implementation of it. Then all existing code will continue to work without change.
Querry?? Write one code example for compile time binding and one for run time bindingQuerry?? What is early/late binding?
An object is early bound when it is assigned to a variable declared to be of a specific object type. Early bound objects allow the compiler to allocate memory and perform other optimizations before an application executes.
' Create a variable to hold a new object.
Dim FS As FileStream
' Assign a new object to the variable.
FS = New FileStream("C:\tmp.txt", FileMode.Open)
By contrast, an object is late bound when it is assigned to a variable declared to be of type Object. Objects of this type can hold references to any object, but lack many of the advantages of early-bound objects.
Dim xlApp As Object
xlApp = CreateObject("Excel.Application")
Querry?? How can you write a class to restrict that only one object of this class can be created (Singleton class)?
Use the private access modifier for default constructor and use static getinstance method to create an intenace, if already one is not present.
Querry?? Difference between type constructor and instance constructor ? What is static constructor, when it will be fired? And what is its use?
(Class constructor method is also known as type constructor or type initializer)
Instance constructor is executed when a new instance of type is created and the class constructor is executed after the type is loaded and before any one of the type members is accessed. (It will get executed only 1st time, when we call any static methods/fields in the same class.) Class constructors are used for static field initialization. Only one class constructor per type is permitted, and it cannot use the vararg (variable argument) calling convention.
A static constructor is used to initialize a class. It is called automatically to initialize the class before the first instance is created or any static members are referenced.
Querry?? What is Private Constructor? and it’s use? Can you create instance of a class which has Private Constructor?
A: When a class declares only private instance constructors, it is not possible for classes outside the program to derive from the class or to directly create instances of it. (Except Nested classes)
Make a constructor private if:
- You want it to be available only to the class itself. For example, you might have a special constructor used only in the implementation of your class' Clone method.
- You do not want instances of your component to be created. For example, you may have a class containing nothing but Shared utility functions, and no instance data. Creating instances of the class would waste memory.
? I have 3 overloaded constructors in my class. In order to avoid making instance of the class do I need to make all constructors to private?
(yes)
? Overloaded constructor will call default constructor internally?
(no)
Querry?? What is check/uncheck?
Querry?? What is Asynchronous call and how it can be implemented using delegates?
Querry?? How to create events for a control?? What is custom events? How to create it?
Querry?? without modifying source code if we compile again, will it be generated MSIL again?
Querry?? What is Params/Ref/Out parameters?-Method Parameters
The params keyword lets you specify a method parameter that takes an argument where the number of arguments is variable.
No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration.
Labels:
Benefits,
Data hiding,
Dot net,
EarlyBinding,
Inheritance,
Object,
Object Oriented Programming,
OOPS,
Polymorphism,
Querry,
Software Complexity,
StaticBinding,
StaticLinking.What is Class,
types of Inheritance
Subscribe to:
Posts (Atom)