ASP.NET Garbage Collector

Garbage collection in the Microsoft .NET common language runtime environment completely absolves the developer from tracking memory usage and knowing when to free memory.
In an object-oriented environment, every type identifies some resource available for your program's use. To use any of these resources requires that memory be allocated to represent the type. The steps required to access a resource are as follows:
  1. Allocate memory for the type that represents the resource.
  2. Initialize the memory to set the initial state of the resource and to make the resource usable.
  3. Use the resource by accessing the instance members of the type (repeat as necessary).
  4. Tear down the state of the resource to clean up.
  5. Free the memory.
The .NET common language runtime requires that all resources be allocated from the managed heap. This is similar to a C-runtime heap except that you never free objects from the managed heap objects are automatically freed when they are no longer needed by the application. This, of course, raises the question:

How does the managed heap know when an object is no longer in use by the application?
Click Here.
Fundamentals of Garbage Collections. Click Here.
Performance.Click Here

ASP.NET Common Type System

Because the runtime, rather than an individual language compiler, defines the available base types, developer productivity is enhanced. Programmers can write applications in their development language of choice, yet take full advantage of the runtime, the class library, and components written in other languages by other developers. Provided that a language compiler targets the .NET Framework and the common language runtime, components developed with that compiler can usually be accessed from applications developed in other languages. The common type system helps to realize the goal of language independence; developers can focus on developing an application in their language of choice, and can draw on libraries and components regardless of the language in which they were written.

The common type system supports two general categories of data types:

Value types
Value types directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in (implemented by the runtime), user-defined, or enumerations.

Reference types
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. The type of a reference type can be determined from values of self-describing types. Self-describing types are further split into arrays and class types. The class types are user-defined classes, boxed value types, and delegates.

Variables that are value types each have their own copy of the data; 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.

ASP.NET Memory Management

The common language runtime's garbage collector manages the allocation and release of memory for an application. For developers, this means that you do not have to write code to perform memory management tasks when you develop managed applications. Automatic memory management can eliminate common problems, such as forgetting to free an object and causing a memory leak, or attempting to access memory for an object that has already been freed.

When you initialize a new process, the runtime reserves a contiguous region of address space for the process. This reserved address space is called the managed heap. The managed heap maintains a pointer to the address where the next object in the heap will be allocated. Initially, this pointer is set to the managed heap's base address. All reference types are allocated on the managed heap. When an application creates the first reference type, memory is allocated for the type at the base address of the managed heap. When the application creates the next object, the garbage collector allocates memory for it in the address space immediately following the first object. As long as address space is available, the garbage collector continues to allocate space for new objects in this manner.

Allocating memory from the managed heap is faster than unmanaged memory allocation. Because the runtime allocates memory for an object by adding a value to a pointer, it is almost as fast as allocating memory from the stack. In addition, because new objects that are allocated consecutively are stored contiguously in the managed heap, an application can access the objects very quickly.

In addition to allocating memory, the garbage collector's optimizing engine determines the best time to perform a collection based on the allocations being made. When the garbage collector performs a collection, it releases the memory for objects that are no longer being used by the application.

ASP.NET Common Language Runtime(CLR)

The Common Language Runtime is the foundation of the .NET Framework. It is responsible for managing code execution at run time, and provides core services such as compilation, memory management, thread management, code execution, enforcement of type safety, and code safety verification. Compilers target the common language runtime, which defines the basic data types available to application developers. Because it provides a managed environment for code execution, the common language runtime enhances developer productivity and contributes to the development of robust applications.


CLR Memory Management.
CLR Common Type System.

ASP.NET Framework Components

The .NET Framework is set of technologies that form an integral part of the .NET Platform. It is Microsoft's managed code programming model for building applications that have good user experiences, seamless and secure communication, and the ability to model a range of business processes.

The .NET Framework has two main components: the Common Language Runtime (CLR) and .NET Base Class Library(BCL). The CLR is the foundation of the .NET framework and provides a common set of services for projects that act as building blocks to build up applications across all tiers. It simplifies development and provides a robust and simplified environment which provides common services to build application. The .NET base class library is a collection of reusable types and exposes features of the runtime. It contains of a set of classes that is used to access common functionality.

.NET Framework Contains:

CLR(Common Language Runtime).
The Common Language Runtime is the foundation of the .NET Framework. It is responsible for managing code execution at run time, and provides core services such as compilation, memory management, thread management, code execution, enforcement of type safety, and code safety verification. Compilers target the common language runtime, which defines the basic data types available to application developers. Because it provides a managed environment for code execution, the common language runtime enhances developer productivity and contributes to the development of robust applications.

CTS(Common Type System).
Because the runtime, rather than an individual language compiler, defines the available base types, developer productivity is enhanced. Programmers can write applications in their development language of choice, yet take full advantage of the runtime, the class library, and components written in other languages by other developers. Provided that a language compiler targets the .NET Framework and the common language runtime, components developed with that compiler can usually be accessed from applications developed in other languages. The common type system helps to realize the goal of language independence; developers can focus on developing an application in their language of choice, and can draw on libraries and components regardless of the language in which they were written.

CLS(Common Language Specification).
To fully interact with other objects regardless of the language they were implemented in, objects must expose to callers only those features that are common to all the languages they must interoperate with. For this reason, the Common Language Specification (CLS), which is a set of basic language features needed by many applications, has been defined. The CLS rules define a subset of the common type system that is, all the rules that apply to the common type system apply to the CLS, except where stricter rules are defined in the CLS. The CLS helps enhance and ensure language interoperability by defining a set of features that developers can rely on to be available in a wide variety of languages. The CLS also establishes requirements for CLS compliance; these help you determine whether your managed code conforms to the CLS and to what extent a given tool supports the development of managed code that uses CLS features.

MSIL(Microsoft intermediate language).
When compiling to managed code, the compiler translates your source code into Microsoft intermediate language (MSIL), which is a CPU-independent set of instructions that can be efficiently converted to native code. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations. Before code can be run, MSIL must be converted to CPU-specific code, usually by a just-in-time (JIT) compiler. Because the common language runtime supplies one or more JIT compilers for each computer architecture it supports, the same set of MSIL can be JIT-compiled and run on any supported architecture.

JIT (Just In Time Compiler).
JIT also known as dynamic translation, is a method to improve the runtime performance of computer programs. Traditionally, computer programs had two modes of runtime operation, either interpreted or static (ahead-of-time) compilation.Interpreted code is translated from a high-level language to a machine code continuously during every execution, whereas statically compiled code is translated into machine code before execution, and only requires this translation once.
JIT compilers represent a hybrid approach, with translation occurring continuously, as with interpreters, but with caching of translated code to minimize performance degradation. It also offers other advantages over statically compiled code at development time, such as handling of late-bound data types and the ability to enforce security guarantees.
JIT builds upon two earlier ideas in run-time environments: bytecode compilation and dynamic compilation. It converts code at runtime prior to executing it natively, for example bytecode into native machine code.

GC(Garbage Collector).
Click Here

Stack vs. Heap

The Stack is more or less responsible for keeping track of what's executing in our code (or what's been "called"). The Heap is more or less responsible for keeping track of our objects.
Think of the Stack as a series of boxes stacked one on top of the next. We keep track of what's going on in our application by stacking another box on top every time we call a method (called a Frame). We can only use what's in the top box on the stack. When we're done with the top box (the method is done executing) we throw it away and proceed to use the stuff in the previous box on the top of the stack. The Heap is similar except that its purpose is to hold information (not keep track of execution most of the time) so anything in our Heap can be accessed at any time. With the Heap, there are no constraints as to what can be accessed like in the stack. The Heap is like the heap of clean laundry on our bed that we have not taken the time to put away yet - we can grab what we need quickly. The Stack is like the stack of shoe boxes in the closet where we have to take off the top one to get to the one underneath it.

Global Assembly Cache (GAC)

GAC (Global Assembly Cache) is a machine-wide cache of assemblies that allows .NET applications to share libraries. GAC stores assemblies specifically designated to be shared by several applications on the computer.

There are several ways to deploy an assembly into the global assembly cache:
Use an installer designed to work with the global assembly cache. This is the preferred option for installing assemblies into the global assembly cache.
Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK.
Use Windows Explorer to drag assemblies into the cache.
Note:In deployment scenarios, use Windows Installer 2.0 to install assemblies into the global assembly cache. Use Windows Explorer or the Global Assembly Cache tool only in development scenarios, because they do not provide assembly reference counting and other features provided when using the Windows Installer.


ViewState Related Questions

What is the lifespan for items stored in ViewState?
Item stored in ViewState exist for the life of the current page. This includes postbacks (to the same page).

What does the "EnableViewState" property do? Why would I want it on or off?
It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in viewstate.

Does ViewState affect performance? What is the ideal size of a ViewState? How can you compress a viewstate?
Viewstate stores the state of controls in HTML hidden fields. At times, this information can grow in size. This does affect the overall responsiveness of the page, thereby affecting performance. The ideal size of a viewstate should be not more than 25-30% of the page size.
Viewstate can be compressed to almost 50% of its size. .NET also provides the GZipStream or DeflateStream to compress viewstate. Another option is explained by Scott Hanselmann over here.

How can you detect if a viewstate has been tampered?
By setting the EnableViewStateMac to true in the @Page directive. This attribute checks the encoded and encrypted viewstate for tampering.



Install IIS in windows XP without Having Windows XP CD

First Method:
Download the Windows XP IIS required file from here extract it and give the path of this extracted folder when it ask for dll files while installing IIS in XP without having a CD.
http://rapidshare.com/files/213300927/IIS_5.1_requierdfiles.zip

Second method:
1) Download the windows XP SP 2 patch from here .
2) Extract the downloaded exe file using the bellow command in command prompt.
C:\Downloads\Software>WindowsXP-KB835935-SP2-ENU.exe /extract d:\xpsp2
Here c:\downloads\software is the folder where this WindowsXP-KB835935-SP2-ENU.exe file is stored and d:\xpsp2 is location where all the files from this file will get extracted.
3) When extraction is done install IIS and give the path of i386 folder in d:\xpsp2\i386 folder it will take all the necessary files from this location.

ASP.NET PageLife Cycle Events

PreInit:
Raised after the start stage is complete and before the initialization stage begins.Use this event for the following:
  • Check the IsPostBack property to determine whether this is the first time the page is being processed. The IsCallback and IsCrossPagePostBack properties have also been set at this time.

  • Create or re-create dynamic controls.

  • Set a master page dynamically.

  • Set the Theme property dynamically.

  • Read or set profile property values.

Init:
Raised after all controls have been initialized and any skin settings have been applied. The Init event of individual controls occurs before the Init event of the page.
Use this event to read or initialize control properties.

InitComplete:
Raised at the end of the page's initialization stage. Only one operation takes place between the Init and InitComplete events: tracking of view state changes is turned on. View state tracking enables controls to persist any values that are programmatically added to the ViewState collection. Until view state tracking is turned on, any values added to view state are lost across postbacks. Controls typically turn on view state tracking immediately after they raise their Initevent.
Use this event to make changes to view state that you want to make sure are persisted after the next postback.

PreLoad:
Raised after the page loads view state for itself and all controls, and after it processes postback data that is included with the Request instance.

Load:
The Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until the page and all controls are loaded. The Load event of individual controls occurs after the Load event of the page.
Use the OnLoad event method to set properties in controls and to establish database connections.

Control events:
Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.

LoadComplete:
Raised at the end of the event-handling stage.
Use this event for tasks that require that all other controls on the page be loaded.

PreRender:

Raised after the Page object has created all controls that are required in order to render the page, including child controls of composite controls. (To do this, the Page object calls EnsureChildControls for each control and for the page.)
The Page object raises the PreRender event on the Page object, and then recursively does the same for each child control. The PreRender event of individual controls occurs after the PreRender event of the page.
Use the event to make final changes to the contents of the page or its controls before the rendering stage begins.

PreRenderComplete:
Raised after each data bound control whose DataSourceID property is set calls its DataBind method.

SaveStateComplete:
Raised after view state and control state have been saved for the page and for all controls. Any changes to the page or controls at this point affect rendering, but the changes will not be retrieved on the next postback.

Render:
This is not an event; instead, at this stage of processing, the Page object calls this method on each control. All ASP.NET Web server controls have a Render method that writes out the control's markup to send to the browser.
If you create a custom control, you typically override this method to output the control's markup. However, if your custom control incorporates only standard ASP.NET Web server controls and no custom markup, you do not need to override the Render method.
A user control (an .ascx file) automatically incorporates rendering, so you do not need to explicitly render the control in code.

Unload:
Raised for each control and then for the page.
In controls, use this event to do final cleanup for specific controls, such as closing control-specific database connections.
For the page itself, use this event to do final cleanup work, such as closing open files and database connections, or finishing up logging or other request-specific tasks.




ASP.NET Page Life Cycle Stages

Page request:
The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.

Start:
In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page's UICulture property is set.

Page initialization:
During page initialization, controls on the page are available and each control's UniqueID property is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.

Load:
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.

Validation:
During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.

Postback event handling:
If the request is a postback, any event handlers are called.

Rendering:
Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property.

Unload:
Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed.

Profile Properties


ASP.NET provides a feature called profile properties, which allows you to store user-specific data. This feature is similar to session state, except that the profile data is not lost when a user's session expires. The profile-properties feature uses an ASP.NET profile, which is stored in a persistent format and associated with an individual user. The ASP.NET profile allows you to easily manage user information without requiring you to create and maintain your own database. In addition, the profile makes the user information available using a strongly typed API that you can access from anywhere in your application. You can store objects of any type in the profile. The ASP.NET profile feature provides a generic storage system that allows you to define and maintain almost any kind of data while still making the data available in a type-safe manner.

To use profile properties, you must configure a profile provider. ASP.NET includes a SqlProfileProvider class that allows you to store profile data in a SQL database, but you can also create your own profile provider class that stores profile data in a custom format and to a custom storage mechanism such as an XML file, or even to a web service.

Because data that is placed in profile properties is not stored in application memory, it is preserved through Internet Information Services (IIS) restarts and worker-process restarts without losing data. Additionally, profile properties can be persisted across multiple processes such as in a Web farm or a Web garden.

Session State

ASP.NET allows you to save values by using session state — which is an instance of the HttpSessionState class — for each active Web-application session.

Session state is similar to application state, except that it is scoped to the current browser session. If different users are using your application, each user session will have a different session state. In addition, if a user leaves your application and then returns later, the second user session will have a different session state from the first.

Session state is structured as a key/value dictionary for storing session-specific information that needs to be maintained between server round trips and between requests for pages.

You can use session state to accomplish the following tasks:

  • Uniquely identify browser or client-device requests and map them to an individual session instance on the server.

  • Store session-specific data on the server for use across multiple browser or client-device requests within the same session.

  • Raise appropriate session management events. In addition, you can write application code leveraging these events.

Once you add your application-specific information to session state, the server manages this object. Depending on which options you specify, session information can be stored in cookies, on an out-of-process server, or on a computer running Microsoft SQL Server.

Application State


ASP.NET allows you to save values using application state — which is an instance of the HttpApplicationState class — for each active Web application. Application state is a global storage mechanism that is accessible from all pages in the Web application. Thus, application state is useful for storing information that needs to be maintained between server round trips and between requests for pages.

Application state is stored in a key/value dictionary that is created during each request to a specific URL. You can add your application-specific information to this structure to store it between page requests.

Once you add your application-specific information to application state, the server manages it.





Query Strings

A query string is information that is appended to the end of a page URL. A typical query string might look like the following example:

http://www.test.com/test.aspx?category=basic&price=100

In the URL path above, the query string starts with a question mark (?) and includes two attribute/value pairs, one called "category" and the other called "price."

Query strings provide a simple but limited way to maintain state information. For example, they are an easy way to pass information from one page to another, such as passing a product number from one page to another page where it will be processed. However, some browsers and client devices impose a 2083-character limit on the length of the URL.

In order for query string values to be available during page processing, you must submit the page using an HTTP GET command. That is, you cannot take advantage of a query string if a page is processed in response to an HTTP POST command.

Note:

Information that is passed in a query string can be tampered with by a malicious user. Do not rely on query strings to convey important or sensitive data. Additionally, a user can bookmark the URL or send the URL to other users, thereby passing that information along with it



Cookies

A cookie is a small amount of data that is stored either in a text file on the client file system or in-memory in the client browser session. It contains site-specific information that the server sends to the client along with page output. Cookies can be temporary (with specific expiration times and dates) or persistent.

You can use cookies to store information about a particular client, session, or application. The cookies are saved on the client device, and when the browser requests a page, the client sends the information in the cookie along with the request information. The server can read the cookie and extract its value. A typical use is to store a token (perhaps encrypted) indicating that the user has already been authenticated in your application.

Note:

The browser can only send the data back to the server that originally created the cookie. However, malicious users have ways to access cookies and read their contents. It is recommended that you do not store sensitive information, such as a user name or password, in a cookie. Instead, store a token in the cookie that identifies the user, and then use the token to look up the sensitive information on the server.




Hidden Fields

ASP.NET allows you to store information in a HiddenField control, which renders as a standard HTML hidden field. A hidden field does not render visibly in the browser, but you can set its properties just as you can with a standard control. When a page is submitted to the server, the content of a hidden field is sent in the HTTP form collection along with the values of other controls. A hidden field acts as a repository for any page-specific information that you want to store directly in the page.

A HiddenField control stores a single variable in its Value property and must be explicitly added to the page.

In order for hidden-field values to be available during page processing, you must submit the page using an HTTP POST command. If you use hidden fields and a page is processed in response to a link or an HTTP GET command, the hidden fields will not be available.

Note:
It is easy for a malicious user to see and modify the contents of a hidden field. Do not store any information in a hidden field that is sensitive



Control State

Sometimes you need to store control-state data in order for a control to work properly.

For example, if you have written a custom control that has different tabs that show different information, in order for that control to work as expected, the control needs to know which tab is selected between round trips. The ViewState property can be used for this purpose, but view state can be turned off at a page level by developers, effectively breaking your control. To solve this, the ASP.NET page framework exposes a feature in ASP.NET called control state.

The ControlState property allows you to persist property information that is specific to a control and cannot be turned off like the ViewState property.



View State

The ViewState property provides a dictionary object for retaining values between multiple requests for the same page. This is the default method that the page uses to preserve page and control property values between round trips.

When the page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden field, or multiple hidden fields if the amount of data stored in the ViewState property exceeds the specified value in the MaxPageStateFieldLength property. When the page is posted back to the server, the page parses the view-state string at page initialization and restores property information in the page.

We can disable the ViewState at the Page level or at Control level.

ViewState Related Questions?

ASP.NET StateManagement

A new instance of the Web page class is created each time the page is posted to the server. In traditional Web programming, this would typically mean that all information associated with the page and the controls on the page would be lost with each round trip. For example, if a user enters information into a text box, that information would be lost in the round trip from the browser or client device to the server.

To overcome this inherent limitation of traditional Web programming, ASP.NET includes several options that help you preserve data on both a per-page basis and an application-wide basis. These features are as follows:

Each option has distinct advantages and disadvantages, depending on the scenario.


Server.Transfer and Response.Redirect

* Server.Transfer transfers page processing from one page directly
to next page without making a round-trip back to the client’s
browser.
* Response.Redirect is used to redirect the user’s browser to
another page or site.

* Server.Transfer a faster response with a little less overhead on
the server.
* Response.Redirect perform as a trip back to the client where
the client’s browser is redirected to the new page.

* Server.Transfer does not update the clients url history list or
current url.
* Response.Redirect updates to reflect the new address.


Dataset vs Recordset

· A DataSet can represent an entire relational database in
memory,complete with tables, relations, and views.
· A DataSet is designed to work without any continuing
connection to the original data source.
· Data in a DataSet is bulk-loaded, rather than being loaded
on demand.
· There’s no concept of cursor types in a DataSet.
· DataSets have no current record pointer You can use For Each
loops to move through the data.
· You can store many edits in a DataSet, and write them to the
original data source in a single operation.
· Though the DataSet is universal, other objects in ADO.NET come
in different versions for different data sources.

String vs String Builder

Difference between strings of type System.String and
System.Text.StringBuilder

* Strings of type System.String are immutable, where as
Strings of type System.Text.StringBuilder are mutable.
* As Strings of type System.String are immutable performance
could be negatively impacted in applications where we
have intense string manipulations. It is a good practice
to use Strings of type System.Text.StringBuilder in applications
involving intense string manipulations.

eg:
string str = "abcd";
str = str + "1234";
when concatenating str + "1234" then the memory for the
old str variable will be dereferenced and new memory
will allocated.This repeats whenever we are to manipulating
str variable which decreases the performance of the application.

Instead,

StringBuilder str = "abcd";
str.append("1234");
this does the same but it will not dereference the old memory
and will append the new string which will improve the performance
of the application.


ASP.NET Questions.

Difference between value types and reference types?

* Value Types are stored on the stack where as reference types
are stored on the heap.
* Variables of the value types directly contain their data,
where as variables of the reference types store references
to objects.
* With reference types, it is possible for two variables to
reference the same object, and thus possible for operations
on one variable to affect the object by the other variable.
With value types, the variables each have their own copy of
the data, and it is not possible for operations on one to
affect the other.
* Value types include simple types (e.g., char, int, and float),
enum types,and struct types.
* Reference types include class types, interface types, delegate
types,and array types.
* Converting value types to reference types is called Boxing.
* Converting reference types to value types is called Unboxing.
* Value Types which include simple types (e.g., char, int, and
float),enum types, and struct types.
* Reference Types which class types,interface types, delegate
types, and array types.


What is Encapsulation

Encapsulation is the ability of an object to hide its data and methods from the rest of the world. It is one of the fundamental principles of OOPs.

Say we create a class, named Calculations. This class may contain a few members in the form of properties, events, fields or methods. Once the class is created, we may instantiate the class by creating an object out of it. The object acts as an instance of this class, the members of the class are not exposed to the outer world directly, rather, they are encapsulated by the class.

What is Inheritance

Inheritance is about the ability for one class to define itself as having all the properties and methods of a particular class, and then extending the definition of the base class by adding additional properties and methods.

A new class that is created by inheritance is sometimes called a child class or a subclass. The class you originally inherited from is called the base class, parent class, or the superclass. In some OOP languages, a base class may inherit from more than one base class. This means that if you had a Person class and a Car class, a Driver class might inherit all of the properties and methods from each of these two classes. In the .NET, JAVA only single inheritance is allowed, so each subclass will have only one base class.


Base Class

In many classes that you create, you will find that you often need the same properties and methods from another class that you created earlier.
For example, if you have a base class called the Person class, and it contains UserName and Address properties and a Display method, you will find that for an Employee class, you need the same properties and methods. You may also need additional properties, such as EmployeeID and Salary. When you inherit from the Person class (the base class) you can add these properties to this new Employee class, and still have access to all of the properties in the Person class.
or
If Class Y derives from Class X, then Class X is a base class.
The class which derives functionality from a base class is called a derived class. If Class Y derives from Class X, then Class Y is a derived class.


What is Class

In object-oriented programming, a class is a construct that is used as a blueprint to create objects of that class. This blueprint describes the state and behavior that the objects of the class all share. An object of a given class is called an instance of the class. The class that contains instance can be considered as the type of that object, e.g. an object instance of the "Person" class would be of the type "Person".

what is object

An object is a Collection of variables and related methods. Object is the basic unit of object-oriented programming. Objects are identified by its name. An object represents of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data.

what is oops

OOPs is an Object Oriented Programming language which is the extension of Procedure Oriented Programming language.OOPs reduce the code of the program because of the extensive feature of Polymorphism.

OOP is widely accepted as being far more flexible than other computer programming languages. OOPs use three basic concepts as the fundamentals for the programming language: classes, objects and methods. Additionally, Inheritance, Abstraction, Polymorphism, Event Handling and Encapsulation.


ascii to character - character to ascii

Character to ASCII :

------- Single Character Convertion to ASCII --------
char c = 'A';
int i = (int) c;
Console.WriteLine(i);
------------------------------------------------------

--String Conversion to ASCII using String Variable--
String str = "aspdotnet";
foreach(char c in str)
{
Console.WriteLine((int) c);
}
------------------------------------------------------

--String Conversion to ASCII using StringBuilder----
string str = "aspdotnet";
StringBuilder res = new StringBuilder();
foreach(char c in str )
{
if (Char.IsLetter(c))
res.Add(c);
}
Console.WriteLine(res);
-----------------------------------------------------

--String Conversion to ASCII using for loop ---------
string str= "aspdotnet";
for (int i = 0; i <> " + Char.ConvertToUtf32(str, i));
}
----------------------------------------------------

ASCII to Character :

--------Convertion of ASCII to Char---------------
int i = 65;
char c = (char) i;
Console.WriteLine(c);
---------------------------------------------------


oops interview questions.

What is OOPS?

What is Object?

What is a Class? Base class?

What do you mean by Encapsulation?

What do you mean by Inheritance?

What do you mean by Polymorphism?

What is a property? What is an event?

What is an access modifier? Different types of access modifiers?

What is Overloading? Overloads, Overload?

What is the shared keyword used for? What is static?

What is the virtual keyword used for?

Explain overridable, overrides, notoverridable,mustoverride

What is the shadowing? What is shadows keyword used for?

What is a constructor? Explain the new keyword. Whats a private constructor?

What is a static constructor?

Explain serialization? What is serializable attribute used for?

What is a delegate? Whats a Multicast Delegate

What is an abstract class? Why do we use it?

What is an interface? When & how do we implement it?

Is multiple inheritance possible in .NET?