Friday, August 19, 2011

Read Configuration Settings of Web.config using Javascript

In Default.aspx (Head Section)
.....Javascript......
function ReadConfigSettings()
{
var conn = '<%=ConfigurationManager.ConnectionStrings["MyConnString"].ConnectionString %>'
alert(conn);
}
....end of javascript.....
Call this function on a button click and display the values of the configuration settings
Place a button in youe wrbpage and on OnClientClick call the function

Thursday, August 18, 2011

Design Patterns

Creational Patterns
Factory - This pattern is used to create concrete class instances without specifying the exact class type.
Abstract Factory - This pattern is used to create concrete class instances without specifying the exact class type. The Abstract Factory Pattern provides a way to encapsulate a group of individual factories that have a common theme.

Flyweight - A pattern used to maximize the sharing of objects resulting in reduced memory consumption.
Singleton - This pattern insures that only a single instance of a given object can exist.
Builder - This pattern separate the construction of a complex object from its representation so that the same construction process can create different representations..

Important Questions

1.What important standard is used to connect client browsers with web servers ?
Ans:TCP/IP
2.What ASP.NET object is used to get information about the web servers ?
Ans:The Server object
3.What method(s) must be used with the Application object to ensure that only one process accesses a variable at a time ?
Ans:Lock() and UnLock()
4.When an ASP.NET server control is added to a Web Form, Visual Studio .NET adds one item to the class for the form. What item is added ?
Ans:A default event handler for the click event
5.What HTML element is the asp:Label control rendered as when the target is Internet Explorer ?
Ans:Span
6.What is the Web.config file used for ?
Ans:To store the global information and variable definitions for the application
7. After capturing the SelectedIndexChanged event for a ListBox control, you find that the event handler doesn’t execute. What could the problem be ?
Ans:The AutomaticPostBack attribute is set to False
8.What method must be overridden in a custom control ?
Ans:The render method
9.Can two different .net programming languages be mixed in a single ASPX file ?
Ans:No
10.How to protect view state from tampering when it's passed over an unencrypted channel ?
Ans:In Page directive set EnableViewStateMac="true"

What is the operation that you can not do with primitive types

Create a new instance of primitive type with New keyword

what is a resource file?

Resource files are the files containing data that is logically deployed with an application. These files can contain data in a number of formats including strings, images and persisted objects. It has the main advantage of if we store data in these files then we don't need to compile these if the data get changed. In .NET we basically require them storing culture specific information's by localizing application's resources. You can deploy your resources using satellite assemblies.

Resource Files are most benificial while developing multilingual Web applications. This feature has been included in ASP.Net 2.0, which provides a declarative model for Resource handling through Resource Expressions (Sub-feature of the overall feature). ASP.NET v2.0 provides automatic support for resource (RESX or RESOURCE) files that follow a specific naming convention and that reside in specialized folders within the application. Hence we can add resource files without any compilation step or satellite assemblies. This enables the developer to provide resources that can be scoped to a page or an application. The ASP.NET runtime uses the .NET Framework ResourceManager to perform resources lookup.
There are 2 types of Resouce files :
1.Global Resource file : This file is present in a specialized folder called /App_GlobalResources, located at the root of the application. All pages, user-controls, etc. can access these resources, so they typically are used as shared resources. The resources which should be available throughout the application are stored in this file.
2.Local Resource file : These files are present in /App_LocalResources folder. These files follow the naming convention of the associated page, user-control, or master-page, along with the culture definition. These files are only accessible by the associated page.

Explain how PostBacks work, on both the client-side and server-side. How do I chain my own JavaScript into the client side without losing PostBack functionality?

From StackOverflow: Postbacks are an abstraction on top of web protocols which emulate stateful behavior over a stateless protocol. On the client side, postbacks are achieved by javascript calls and hidden fields which store the state of all controls on the page. The server side goes through a life cycle of events, port of that life cycle is the hydration of the viewstate to maintain the state of all controls on the page, and the raising of events based on the parameters that were passed into the __doPostBack call on the client side.

Depending on your requirements, you can use control events like OnClientClick to chain in your client side JavaScript, or you can use the GetPostBackEventReference method to give your scripts access to the postback method on the client side.

What are ASHX files? What are HttpHandlers? Where can they be configured?

An .ashx file is a placeholder for an HttpHandler. It allows you to create a IHttpHandler implementation as simply as you create a .aspx file, without any reconfiguration of web.config or other hoops. It provides you access to the Request and Responsie without any of the facilities or overhead of the page model.

HttpHandlers are low level implementations of the request/response http cycle. Using an HttpHandler, you can deliver responses back to the browser with minimal overhead. A good example of this would be a dynamic image generator that could be accessed using the tag.

You configure HttpHandlers by registering them in web.config. You may also need to configure IIS to send certain file extension requests to aspnet_isapi.dll.

From constructor to destructor (taking into consideration Dispose() and the concept of non-deterministic finalization), what the are events fired as part of the ASP.NET System.Web.UI.Page lifecycle. Why are they important? What interesting things can you do at each?

Object Initialization (Server object and page object instantiated)
PreInit (Add dynamic controls)
Init (Change control initialization values after control init)
InitComplete (All controls initialized)
PreLoad (Before stat loads)
Load (State has been loaded) (Page called first, then controls)
Control Events (Events caused by postback)
LoadComplete (Post post-back processing)
PreRender (last changes to viewstate)
SaveStateComplete (post-viewstate processing)
Render (generate html)
UnLoad (cleanup)
Dispose (objects destroyed)

Monday, August 8, 2011

Why we should give preference to stored procedure?

A stored procedure is a group of SQL statements that have been created and stored in a database. A procedured can accept input parameters. When the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve performance. Stored procedures can be used to help ensure the integrity of the database.

Procedure Cache is the place where Execution Plan of Stored Procedure is stored. An execution plan states the efficient way in which the query(s) is executed. So whenever a normal query is executed its Execution Plan is created but when a Stored Procedure is executed, Execution plan is created and stored in Procedure Cache. Whenever the same procedure is executed and its execution plan exists in Procedure cache then it uses that execution plan rather than creating a new plan.

What is an extent?

Extent is a basic unit of storage to provide space for tables. Every extent has a number of data pages. As new records are inserted new data, pages are allocated. There are eight data pages in an extent. So as soon as the eight pages are consumed, it allocates a new extent with data pages.

While extent is basic unit storage from a database point of view, page is a unit of allocation within extent.

What are IMPLICIT TRANSACTIONS?

Implicit Transactions are those that requires a COMMIT or ROLLBACK for every transaction.

When ON, SET IMPLICIT_TRANSACTIONS sets the connection into implicit transaction mode. When OFF, it returns the connection to autocommit transaction mode.

For example if we turn it on & update a table, the changes will not be committed until COMMIT command is executed.

What is the advantage of SET NOCOUNT ON in sql procedure

SET NOCOUNT ON gives a performance boost to action queries by suppressing the "(n row(s) affected) message that results from running a query.

Qualifying an object with it's owner boosts performance because SQL does not have to work out where if there is a user specific version of the same object. It also gives benefits in the caching of execution plans.

The performance boost is due to the few bytes of information that make up the "(1 row(s) affected)" message not being transmitted to the client application.

Monday, August 1, 2011

6 important .NET concepts: - Stack, heap, Value types, reference types, boxing and Unboxing.

When you declare a variable in a .Net application, it allocates some chunk of memory in to the RAM. This memory has 3 things first the name of the variable, second data type of the variable and finally the value of the variable.

That was a simple explanation of what happens in the memory, but depending on what kind of data type your variable is allocated on that type of memory. There are two types of memory allocation stack memory and heap memory.

Stack and Heap
In order to understand stack and heap, let’s understand what actually happens in the below code internally.

public void Method1()
{// Line 1
int i=4;
// Line 2
int y=2;
//Line 3
class1 cls1 = new class1();
}

It’s a 3 line code so let’s understand line by line how things execute internally.
Line 1:- When this line is executed compiler allocates a small amount of memory in to memory type called as stack. Stack is responsible of keeping track of running memory needed in your application.

Line 2:- Now the execution moves to the next step. As the name says stack it stacks this memory allocation on the top of the first memory allocation. You can think about stack as series of compartment or boxes put on top of each other.
Memory allocation and de-allocation is done using LIFO (Last in first out) logic. In other words memory is allocated and de-allocated at only one end of the memory i.e. top of the stack.

Line 3:- In line 3 we have a created an object. When this line is executed it creates a pointer on the stack and the actual object is stored in a different type of memory location called as ‘Heap’. ‘Heap’ does not track
running memory it’s just pile of objects which can reached at any moment of time. Heap is used for dynamic memory allocation.

One more important point to note here is reference pointers are allocated on stack. The statement, Class1 cls1; does not allocate memory for an instance of Class1, it only allocates a stack variable cls1 (and sets it to null). The time it hits the new keyword it allocates on "HEAP".

Execution:-
Now finally the execution control starts exiting the method. When it passes the end control it clears all the memory variables which are assigned on stack. In other words all variables which are related to ‘int’ data type are de-allocated in ‘LIFO’ fashion from the stack.
The BIG catch – It did not de-allocate the heap memory. This memory will be later de-allocated by “GARBAGE COLLECTOR”.

Value types and reference types
Now that we have understood the concept of ‘Stack’ and ‘Heap’ it’s time to understand the concept of value types and reference types.
Value types are types which hold both data and the memory on the same location. While a reference type has a pointer which points to the memory location.
Below is a simple integer data type with name ‘i’ whose value is assigned to an other integer data type with name ‘j’. Both these memory values are allocated on the stack.
When we assign the ‘int’ value to the other ‘int’ value it creates a complete different copy. In other word if you change either of them the other does not change. These kinds of data types are called as ‘Value types’.

When we create an object and when we assign one object to the other object, they both point to the same memory location as show in the below code snippet. So when we assign ‘obj’ to ‘obj1’ they both point to the same memory location.
In other words if we change one of them the other object is also affected this is termed as ‘Reference types’.

So which data types are ref type and value type?
In .NET depending on data types the variable is either assigned on the stack or on the heap. ‘String’ and ‘Objects’ are reference types and any other .NET primitive data types are assigned on the stack.

Boxing and Unboxing
When we move a value type to reference type the data is moved from the stack to the heap. When we move reference type to a value type the data is moved from the heap to the stack.This movement of data from the heap to stack and vice-versa creates a performance hit.

When the data moves from value types to reference types its termed as ‘Boxing’ and the vice versa is termed as ‘UnBoxing’.

SQL Server: JOIN vs IN vs EXISTS - the logical difference

There is a common misconception that IN behaves equaliy to EXISTS or JOIN in terms of returned results.

This is simply not true. To see why not, let's review what each statement does.

IN:
Returns true if a specified value matches any value in a subquery or a list.

Exists:
Returns true if a subquery contains any rows.

Join:
Joins 2 resultsets on the joining column.

From where we can set the Session Time Out in IIS ?

We can set the Session time out settings from the Virtual Directory for that site.

Right Click on Virtual Directory > Properties > Click on "Configuration" Button.Goto the "Option" Tab. There in Enable Session State Section you can configure the Session Timeout .

What is the default user name of an anonymous login in IIS?

In IIS, an anonymous user will be given with a user name of "IUSR_MachineName"

what are the Error & Status codes in IIS 6.0?

100 Series - Informational
200 Series - Success
300 Series - Redirection
400 Series - Client Error
500 Series - Server Error

What are the Different steps to be followed to get SSL(Secure Sockets Layer) for our Web Application ?

1.Intially we have to Generate a certificate request from our IIS

2. Now we have to request a certificate from the certificate authority(CA)

3. This CA is an entity which issues Digital Certificates.

4. After receiving the certificate we have to install that particular certificate on our Web Server using IIS

5. We have to use Secure Hyper Text Transfer Protocol(HTTPS) when accessing secure pages in our application.

By this way we could make our web page as SSL protected. !!!

Find Duplicate Records in SQL

select employee, firstname, lastname, dob
from employees (nolock)
where employee in
(select employee from employees (nolock)
group by employee
having count(employee)>1)
order by employee

What is AL.EXE and Resgen.EXE

Resgen.exe performs conversion of .txt / .restext files to .resources / .resx files and vice-versa. These (.resources/.resx) files can be embedded in a runtime binary executable or compiled into satellite assemblies.

Assembly Linker (Al.exe) generates a file that has an assembly manifest from modules or resource files. A module does not have an assembly manifest.

What is partial classess in .net?

When there is a need to keep the business logic separate from the User Interface or when there is some class which is big enough to have multiple number of developers implement the methods in it, the class can be separated and written in different files as partial class.

The keyword partial must appear in each class.


//syntax for C#
Public partial class MyPartialClass1
{
//code
}

// this code could be in file1

Public partial class MyPartialClass1
{
//code
}
// this code could be in file2

Partial classes allow us to divide the class definition into multiple files (physically). Logically, all the partial classes are treated as a single file by the compiler.

Define most commonly used interfaces in Net Framework.

IComparable: It is implemented by types for ordering and sorting. The implementation types must implement one single method i.e. CompareTo.

IDisposable:This is implemented to manage release of unmanaged resources from memory. The garbage collector acts on its own and hence the Dispose method is used to call the garbage collector to free unmanaged resources through this interface.

IConvertible: It is implemented to convert value of the implementing type into another CLR compatible type. If the conversion fails then an invalidcastexception is thrown.

ICloneable: Allows creating objects of a class having same values as another instance using the Clone method.

IEquatable:Implemented to create type specific methods to know the equality between various objects.

IFormattable:Implemented to convert object into string representations. Objects can define their own specific string representation through this interface’s ToString() method.

What are the various components in crystal reports?

When .NET application uses crystal reports, the following components are required:

•Report files: .rpt or report files needs to be distributed which can either be compiled into the application (Embedded) or independently (non embedded) from the application.
•Crystal reports merge module: The merge module ensures that the correct report components and component versions are installed with the application.
•.Net Framework: - .Net framework must be available on the client machine

Explain the situations you will use a Web Service and Remoting in projects.

Web services should be used if the application demands communication over a public network and require to work across multiple platforms. Remoting is faster comparatively and hence can be used in .Net components when performance is a high priority. Few applications can also make use of BOTH web services and Remoting to send and receive data not just across multiple platforms but also between .Net applications where performance and speed is a key priority.

Explain the situations you will use a Web Service and Remoting in projects.

Web services should be used if the application demands communication over a public network and require to work across multiple platforms. Remoting is faster comparatively and hence can be used in .Net components when performance is a high priority. Few applications can also make use of BOTH web services and Remoting to send and receive data not just across multiple platforms but also between .Net applications where performance and speed is a key priority.

What is Service Oriented architecture?

Service oriented architecture is based on services. Service is a unit of some task performed by a service provider in order to satisfy the consumer. Example of such a service is the web services used in .NET. Even though the main purpose of web services is to enable communication, it may differ from application to application. SOA provides a set of policies and frameworks to ensure the desired services are delivered to the consumer.

What is the GAC? What problem does it solve?

Global Assembly Cache (GAC):

Any system that has the CLR (common language runtime) installed, has a machine-wide code cache known as GAC.

Assemblies deployed in the global assembly cache need to have a strong name.

The Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK can be used to deploy assemblies to GAC.

What is the GAC? What problem does it solve?

Global Assembly Cache (GAC):

Any system that has the CLR (common language runtime) installed, has a machine-wide code cache known as GAC.

Assemblies deployed in the global assembly cache need to have a strong name.

The Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK can be used to deploy assemblies to GAC.

What is a PID? How is it useful when troubleshooting a system?

PID stands for Process Identifier.
It is a uniquely assigned integer that identifies a process in an OS.
It is used in diagnosing the problems with the process in Multi-Tasking systems.

What is strong-typing versus weak-typing? Which is preferred? Why?

In weak typing, it is allowed to define a block of memory as another type (casting).
Languages like C, C++ are weakly and statically typed.
Languages like Perl and PHP are weakly typed as you can add numbers to strings and they will implicitly coerce it.

Languages like Java, C# and Python are strongly typed. In these the type conversion needs to be explicitly handled.

For scripts we use weak typing.

In big programs, we use strong typing which can reduce errors at compile time.

What is a Windows Service and how does its lifecycle differ from a "standard" EXE?

A service opens before one log in. However, a standard exe can be opened after a log in only.

Windows Service applications are long-running applications that do not have a user interface. They do not even produce any visual output.
The user messages are written to the Windows Event Log.
Services can run under the context of any user or a system. They are controlled by the Service Control Manager by which they can be stopped, paused, and started.

What is the use of System.Environment class in C#.NET?

The System.Environment class can be used to retrieve information like:
command-line arguments
the exit code
environment variable settings
contents of the call stack
time since last system boot
the version of the common language runtime.

What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?

•XML Web services are more restricted than objects exposed over .NET Remoting.
•XML Web services support open standards that target cross-platform use.
•XML Web services are generally easier to create and due to the restricted nature of XML Web services, the design issues are simplified.
•XML Web services support only SOAP message formatting, which uses larger XML text messages.
•Communication with .NET Remoting can be faster than XML Web service communication with a binary formatter.
•XML Web services are designed for use between companies and organizations.
•XML Web services don't require a dedicated hosting program because they are always hosted by ASP.NET.
•Consumers can use XML Web services just as easily as they can download HTML pages from the Internet. Thus there's no need for an administrator to open additional ports on a firewall as they work through MS-IIS and ASP.NET

What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?

•XML Web services are more restricted than objects exposed over .NET Remoting.
•XML Web services support open standards that target cross-platform use.
•XML Web services are generally easier to create and due to the restricted nature of XML Web services, the design issues are simplified.
•XML Web services support only SOAP message formatting, which uses larger XML text messages.
•Communication with .NET Remoting can be faster than XML Web service communication with a binary formatter.
•XML Web services are designed for use between companies and organizations.
•XML Web services don't require a dedicated hosting program because they are always hosted by ASP.NET.
•Consumers can use XML Web services just as easily as they can download HTML pages from the Internet. Thus there's no need for an administrator to open additional ports on a firewall as they work through MS-IIS and ASP.NET

Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.

Interface oriented approach compels to develop the software based on the contract.
Object oriented approach emphasizes on its aspects like:
Abstraction
Encapsulation
Inheritance
Polymorphism
Cross cutting concerns cannot be implemented in object oriented programming.
That’s not the case with aspect-oriented. However, there is a risk of system failure in this situation.

Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.

Interface oriented approach compels to develop the software based on the contract.
Object oriented approach emphasizes on its aspects like:
Abstraction
Encapsulation
Inheritance
Polymorphism
Cross cutting concerns cannot be implemented in object oriented programming.
That’s not the case with aspect-oriented. However, there is a risk of system failure in this situation.

What is the JIT? What is NGEN? What are limitations and benefits of each?

Just In Time Compiler compiles the code just before it is run.
Due to this the code takes longer time to start however it is more efficient compilation since the compiler has more information about the target system.

NGen is used to pre-just in time code which yields faster startup time but the compiler produces less efficient code because it has less information.

What is the JIT? What is NGEN? What are limitations and benefits of each?

Just In Time Compiler compiles the code just before it is run.
Due to this the code takes longer time to start however it is more efficient compilation since the compiler has more information about the target system.

NGen is used to pre-just in time code which yields faster startup time but the compiler produces less efficient code because it has less information.

How to achieve polymorphism in C#.NET?

Polymorphism is when a class can be used as more than one type through inheritance. It can be used as its own type, any base types, or any interface type if it implements interfaces.

It can be achieved in the following ways:
Derived class inherits from a base class and it gains all the methods, fields, properties and events of the base class.

To completely take over a class member from a base class, the base class has to declare that member as virtual.

How to achieve polymorphism in C#.NET?

Polymorphism is when a class can be used as more than one type through inheritance. It can be used as its own type, any base types, or any interface type if it implements interfaces.

It can be achieved in the following ways:
Derived class inherits from a base class and it gains all the methods, fields, properties and events of the base class.

To completely take over a class member from a base class, the base class has to declare that member as virtual.

What benefit do you get from using a Primary Interop Assembly (PIA)?

A primary interop assembly contains type definitions (as metadata) of types implemented with COM.

Only a single PIA can exist, which needs to be signed with a strong name by the publisher of the COM type library.

One PIA can wrap multiple versions of the same type library.

A COM type library imported as an assembly can be a PIA only if it has been signed and published by the same publisher.

Therefore, only the publisher of a type library can produce a true PIA, that can be considered as the unit of an official type definition for interoperating with the underlying COM types.

What is the use of GetCommandLineArgs() method in C#.NET?

With GetCommandLineArgs() method, the command line arguments can be accessed.
The value returned is an array of strings.

Explain the use of virtual, sealed, override, and abstract.

The virtual keyword enables a class to be overridden. If it has to be prevented from being overridden, then the sealed keyword needs to be used. If the keyword virtual is not used, members of the class can even then be overridden. However, its usage is advised for making the code meaningful.

The override keyword is used to override the virtual method in the base class. Abstract keyword is used to modify a class, method or property declaration. You cannot instantiate an abstract class or make calls to an abstract method directly.

An abstract virtual method means that the definition of the method needs to be given in the derived class.

Explain the use of virtual, sealed, override, and abstract.

The virtual keyword enables a class to be overridden. If it has to be prevented from being overridden, then the sealed keyword needs to be used. If the keyword virtual is not used, members of the class can even then be overridden. However, its usage is advised for making the code meaningful.

The override keyword is used to override the virtual method in the base class. Abstract keyword is used to modify a class, method or property declaration. You cannot instantiate an abstract class or make calls to an abstract method directly.

An abstract virtual method means that the definition of the method needs to be given in the derived class.

What are Extender provider components? Explain how to use an extender provider in the project.

An extender provider is a component that provides properties to other components.

Implementing an extender provider:

•Use the ProvidePropertyAttribute, which specifies the name of the property that an implementer of IExtenderProvider provides to other components, attribute to specify the property provided by your extender provider.
•Implement the provided property.
•Track which controls receive your provided property.
•Implement the IExtenderProvider, which defines the interface for extending properties to other components in a containe, interface.

What are circular references? Explain how garbage collection deals with circular references.

A circular reference is a run-around wherein the 2 or more resources are interdependent on each other rendering the entire chain of references to be unusable.

There are quite a few ways of handling the problem of detecting and collecting cyclic references.

1. A system may explicitly forbid reference cycles.
2. Systems at times ignore cycles when they have short lives and a small amount of cyclic garbage. In this case a methodology of avoiding cyclic data structures is applied at the expense of efficiency.
3. Another solution is to periodically use a tracing garbage collector cycles.
Other types of methods to deal with cyclic references are:
•Weighted reference counting
•Indirect reference counting

Change date format mm/dd/yy to dd/mm/yy using query?

Select CAST(DAY(GETDATE()) AS VARCHAR(2)) + ‘/’ + CAST(MONTH(GETDATE()) AS VARCHAR(2)) + ‘/ ‘ + CAST(YEAR(GETDATE()) AS VARCHAR(4)) AS DATE

Can you edit the data in repeater control?

No, we can only display data.

Can you edit the data in repeater control?

No, we can only display data.

Can you declare the override method static while the original method is non-static?

No, you can’t the signature of the virtual method must remain the same, only the keyword ‘virtual is changed to keyword override’.

What does the Keyword ‘virtual’mean in the method definition?

The method can be over-ridden

Is it possible to insert hyperlinks in ListBox?

It can’t possible adding hyperlinks/links to listbox.
Its just a collection items not child items and are not render while anyone put some html tags. So, its not possible

How can I get the date of Last Monday of specified week?

declare @dt datetime

set @dt=’1/1/2010′ –Want to know January’s Last Monday Date

SELECT dateadd(d,-datepart(dw,DATEADD(d, -datepart(d,dateadd(mm,1,@dt)),dateadd(mm,1,@dt))-1)+1,DATEADD(d, -datepart(d,dateadd(mm,1,@dt)),dateadd(mm,1,@dt)))

Can we store filtered DataView in ViewState?

We can store only objects of the following types:
1. string
2. integers
3. boolean
4. Array
5. ArrayList
6. Hash tables
7. Custom types etc.
Apart from above we can share some other types too but the class must be serialized.
In view of above theory, we can say ‘yes, we can store DataView in ViewState for serialized class.

Can I inherit two difference classes to partial classes?

We can’t inherit two difference classes to partial class because in C# multiple inheritance is not possible using classes.

What are Classes and structures

Structures

A structure in C# is simply a composite data type [you are well aware from composite data type, refer to data types for more details], which consists number of members of other types. The structure define simply by using the struct keyword.

eg. struct enroll
{
public string name, fname, mname;
public string char sex;
Public int age;
public string address;
}

Classes

It is cleared from above study that Classes are reference type. A class is a collection of its data members. Data members are those members of class which contains the data of class like fields, constants and events etc. Class is declared simply just followed by class keyword with optional modifiers; by default C# classes are public.

eg. class myClass
{
public int xyz;
public string name;
public const int y=22;
}

Define interface in own words

An interface is simply a collection of function prototypes. An Interface is a reference type like a class, but interface can contain only abstract members. In other words, Interface is a contract that defines the signature of the functionality.

An interface looks like a class definitions, but its only purpose is to define a set of methods and not to implement them. For this reason the interface definition includes only the definition of methods [in other words the abstract methods]. Interface contains only methods, properties and delegates but can not contain fields, constructors, destructor and any type of static members.