You are on page 1of 11

PRACTICAL NO 1

INTRODUCTION TO .NET FRAMEWORK


.Net Framework is a platform or development environment to seamlessly create web-applications that are accessible through client machines from across the globe. These web-applications adopt open standards such as extensible Markup Language (XML), Hypertext Transfer Protocol (HTTP), and Simple Object Access Protocol (SOAP) to interact with applications that are available in other platforms. .Net Framework is platform independent and language independent. This means that .Net Framework allows you to use different programming languages such as VB.Net, C#, Jscript, VBScript, and Managed C++ and run applications on different platforms such as Unix, Macintosh, and Linux. Moreover, .Net Framework enables you to use various off-the-shelf libraries that help the development of applications faster, easier, and cheaper. .Net Framework now supports over 20 different programming languages.

.NET FRAMEWORK
DOT NET APPLICATION VB.NET, ASP.NET, VC++.NET AND OTHER LANGUAGE

DOT NET FRAMEWORK (FCL) WINDOW FORM ASP.NET CLASSES (CLR) COMMON MANAGED APPLICATION TYPE SYSTEM
Other classes

OPERATING SYSTEM / HARDWARE ANY OPERATING SYSTEM

The .NET Framework is designed to fulfill the following objectives:


y

y y y y y

To provide a consistent object-oriented programming environment whether object code is stored and executed locally, executed locally but Internet-distributed, or executed remotely. To provide a code-execution environment that minimizes software deployment and versioning conflicts. To provide a code-execution environment that promotes safe execution of code, including code created by an unknown or semi-trusted third party. To provide a code-execution environment that eliminates the performance problems of scripted or interpreted environments. To make the developer experience consistent across widely varying types of applications, such as Windows-based applications and Web-based applications. To build all communication on industry standards to ensure that code based on the .NET Framework can integrate with any other code.

Common Language Runtime: The CLR provides common runtime services to all .Net applications. In addition, the CLR reduces the developer's time to write lengthy code for using features such as life-cycle management, strong type naming, cross-language exception handling, and dynamic binding to turn business logic into a reusable component. The .NET Framework provides a run-time environment called the common language runtime, which runs the code and provides services that make the development process easier.

COMPONENT OF CLR

BASE CLASS LIBRARY SUPPORT THREAD SUPPORT EXCEPTION MANAGER TYPE CHECKER CODE MANAGER
IL TO NATIVE CODE

COM MARSHALER SECURITY ENGINE DEBUG ENGINE


GARBAGE COLLECTION

CLASS LOADER

.NET FRAMEWORK CLASS LIBRARY


The .NET Framework includes classes, interfaces, and value types that expedite and optimize the development process and provide access to system functionality. To facilitate interoperability between languages, most .NET Framework types are CLS-compliant and can therefore be used from any programming language whose compiler conforms to the common language specification (CLS). The .NET Framework types are the foundation on which .NET applications, components, and controls are built. The .NET Framework includes types that perform the following functions:
y y y y y y

Represent base data types and exceptions. Encapsulate data structures. Perform I/O. Access information about loaded types. Invoke .NET Framework security checks. Provide data access, rich client-side GUI, and server-controlled, client-side GUI.

The .NET Framework provides a rich set of interfaces, as well as abstract and concrete (nonabstract) classes.

Naming Conventions
System This namespace includes the core needs for programming. It includes base types like String, DateTime, Boolean, and so forth, support for environments such as the console, math functions, and base classes for attributes, exceptions, and arrays. System.Collections Defines many common containers or collections used in programming, such as lists, queues, stacks, hashtables, and dictionaries. It includes support for generics. System.Diagnostics Provides the ability to diagnose applications. It includes event logging, performance counters, tracing, and interaction with system processes. System.Globalization Provides help for writing internationalized applications. "Culture-related information, including the language, the country/region, the calendars in use, [and] the format patterns for dates, currency, and numbers" can be defined.

System.IO Enables reading from and writing to different streams, such as files or other data streams. Also provides a connection to the file system. System.Net Provides an interface "for many of the protocols used on networks today", such as HTTP, FTP, and SMTP. Secure communication is supported by protocols such as SSL. System.Reflection Provides an object view of types, methods, and fields; and "the ability to dynamically create and invoke types".It exposes the API to access the Reflective programming capabilities of CLR. System.Runtime Allows management of the runtime behavior of an application or the CLR. Some of the included abilities are interoperable with COM or other native code, writing distributed applications, and serializing objects into binary or SOAP. System.Security "Provides the underlying structure of the common language runtime security system." This namespace allows security to be built into applications based on policy and permissions. It provides services such as cryptography. System.Text Supports various encodings, regular expressions, and a more efficient mechanism for manipulating strings (StringBuilder). System.Threading Helps facilitate multithreaded programming. It allows the synchronizing of "thread activities and access to data" and provides "a pool of system-supplied threads." System.Xml "Provides standards-based support for processing XML," including reading, writing, schemas, serialization, searching, and transforming. System.ComponentModel Provides the ability to implement the run-time and design-time behavior of components and controls. It contains the infrastructure "for implementing attributes and type converters, binding to data sources, and licensing components."

System.Configuration Provides the infrastructure for handling configuration data. System.Data This namespace represents the ADO.NET architecture, which is a set of computer software components that can be used by programmers to access data and data services. System.Deployment Allows customization of the way applications upgrade when using System.DirectoryServices Provides easy access to Active Directory from managed code. System.Management Allows querying for system information, "such as how much free space is left on the disk, what is the current CPU utilization, which database a certain application is connected to, and much more." System.Media Provides the ability to play system sounds and .wav files. System.Messaging Provides the ability "to connect to, monitor, and administer message queues on the network and send, receive, or peek messages." .NET Remoting is another name for some of the functionality provided. This namespace is being superseded by Windows Communication Foundation. System.Resources Allows management of resources in the application in order to internationalize an application for different cultures and languages. System.Windows.Forms This namespace contains the Windows Forms architecture which provides access to the native Windows interface elements by wrapping the existing Windows API. This allows for writing graphical applications for Windows from within managed code.

.NET CLASS LIBRARY

SYSTEM.DATA DATA SET DATA TABLE

SYSTEM.DIAGNOSTICE
DEBUG TRACE

SYSTEM.IO
FILE FILE SYSTEM PATH ETC

DATA COLUMN

SYSTEM.MATH SQRT LOG COS ETC

SYSTEM.REFLECTION ASSEMBLY MODULE

SYSTEM.SECURITY CRYPTOGRAPH Y PERMISSIONS POLICY

VALUE TYPE AND REFRENCE 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. Below figure explains the same in a more detail manner:

Value Types
y y y y

Value Types refer to actual built in data types, those contain the actual data and stored in memory. Value Types are stored in stack memory locations. If we pass a Value Type variable to a Method(Called Method) as a parameter, then if any changes made by the called method does not reflected back in the calling method. Each Value Type Variable is stored in separate memory locations.

EXAMPLE: 1) As name suggest Value Type stores value directly. 2) For eg: //I and J are both of type int I = 20; J = I; int is a value type, which means that the above statements will results in two locations in memory. 3) For each instance of value type separate memory is allocated. 4) Stored in a Stack. 5) It Provides Quick Access, because of value located on stack.

Reference Types
y y y

A Reference Type variable holds a reference to data rather than containing the actual data. Reference Types are stored on the Heap Memory Locations. ref keyword is used to passing the reference to a method.

EXAMPLE: As name suggest Reference Type stores reference to the value. 2) For eg: Vector X, Y; //Object is defined. (No memory is allocated.) X = new Vector(); //Memory is allocated to Object. //(new is responsible for allocating memory.) X.value = 30; //Initialising value field in a vector class. Y = X; //Both X and Y points to same memory location. //No memory is created for Y. Console.writeline(Y.value); //displays 30, as both points to same memory Y.value = 50; Console.writeline(X.value); //displays 50. Note: If a variable is reference it is possible to indicate that it does not refer to any object by setting its value to null; 3) Reference type are stored on Heap. 4) It provides comparatively slower access, as value located on heap.

PRACTICAL NO 2

Write a program to create structure. CODING


using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication3 { class Program { struct employee { public string name; public int rollnumber; } static void Main(string[] args) { employee e; e.name = " abc "; e.rollnumber=**** Console.WriteLine("Name is " + e.name + " " + " & +e.rollnumber+ "); } } } OUTPUT:

PRACTICAL NO 3 Write a program to create Enumeration type. CODING


using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication2 { class Program { enum week { sun,mon,tue,wed,thu,fri,sat }

static void Main(string[] args) { week w; for(int i=0;i<=6;i++) { w=(week)i; Console.WriteLine(i+1 +"Today is " +w); } } } } OUTPUT: