Sunteți pe pagina 1din 15

Introduction to C# Programming for the Microsoft .

NET Platform (MS2124)


Course Overview The goal of this course is to provide delegates with the knowledge and skills needed to develop C# applications for the Microsoft .NET Platform. The course focuses on C# program structure, language syntax, and implementation details. C# was created to be the programming language best suited for writing .NET enterprise applications. C# combines the high productivity of Microsoft Visual Basic(r) with the raw power of C++. It is a simple, object-oriented, and type-safe programming language that is based on the C and C++ family of languages. What will I learn? Upon completion of this course, delegates will be able to: List the major elements of the .NET Framework and explain how C# fits into the .NET Platform. Analyse the basic structure of a C# application and be able to document, debug, compile, and run a simple application. Create, name, and assign values to variables. Use common statements to implement flow control, looping, and exception handling. Create methods (functions and subroutines) that can return values and take parameters. Create, initialise, and use arrays. Explain the basic concepts and terminology of object-oriented programming. Use common objects and references types. Create, initialise, and destroy objects in a C# application. Build new C# classes from existing classes. Create self-contained classes and frameworks in a C# application. Define operators, use delegates, and add event specifications. Implement properties and indexers. Use predefined and custom attributes. Course Style This course is hands-on with practical exercises throughout. We provide you with individual PC's so that you are able to work alone. Class sizes are kept small so that you will receive personal attention. You will take away extensive printed course material, which will be of on going use to you in your work. Course Contents Overview of the Microsoft .NET Platform Introduction to the .NET Platform

Overview of the .NET Framework Benefits of the .NET Framework The .NET Framework Components Languages in the .NET Framework

Overview of C# Structure of a C# Program Basic Input/Output Operations Recommended Practices Compiling, Running, and Debugging

Value-Type Variables Common Type System Naming Variables Using Built-in Data Types Creating User-Defined Data Types Converting Data Types

Statements & Exceptions Introduction to Statements Using Selection Statements Using Iteration Statements Using Jump Statements Handling Basic Exceptions Raising Exceptions

Methods and Parameters Using Methods Using Parameters Using Overloaded Methods Arrays Overview of Arrays Creating Arrays Using Arrays Essentials of Object-Oriented Programming Classes and Objects Using Encapsulation C# and Object Orientation Defining Object-Oriented Systems

Using Reference-Type Variables Using Reference-Type Variables Using Common Reference Types The Object Hierarchy Namespaces in the .NET Framework Data Conversions

Creating and Destroying Objects Using Constructors Initialising Data Objects and Memory Using Destructors Destroying Objects

Inheritance in C# Deriving Classes Implementing Methods Using Sealed Classes Using Interfaces Using Abstract Classes

Aggregation, Namespaces, and Advanced Scope Using Internal Classes, Methods, and Data Using Aggregation Using Namespaces Using Modules and Assemblies

Operators and Events Introduction to Operators Defining and Using Events Operator Overloading Creating and Using Delegates

Properties and Indexers Using Properties Using Indexers Attributes Overview of Attributes

Defining Custom Attributes Retrieving Attribute Values Prerequisites Before attending this course, delegates must have: Experience with programming in C, C++, Visual Basic, Java, or another programming language. Familiarity with Microsoft's .NET strategy. Recommended Follow-On Courses No Recommended follow-on courses

ADO .NET
Most applications need data access at one point of time making it a crucial component when working with applications. Data access is making the application interact with a database, where all the data is stored. Different applications have different requirements for database access. VB .NET uses ADO .NET (Active X Data Object) as it's data access and manipulation protocol which also enables us to work with data on the Internet. Let's take a look why ADO .NET came into picture replacing ADO. Evolution of ADO.NET The first data access model, DAO (data access model) was created for local databases with the built-in Jet engine which had performance and functionality issues. Next came RDO (Remote Data Object) and ADO (Active Data Object) which were designed for Client Server architectures but soon ADO took over RDO. ADO was a good architecture but as the language changes so is the technology. With ADO, all the data is contained in a recordset object which had problems when implemented on the network and penetrating firewalls. ADO was a connected data access, which means that when a connection to the database is established the connection remains open until the application is closed. Leaving the connection open for the lifetime of the application raises concerns about database security and network traffic. Also, as databases are becoming increasingly important and as they are serving more people, a connected data access model makes us think about its productivity. For example, an application with connected data access may do well when connected to two clients, the same may do poorly when connected to 10 and might be unusable when connected to 100 or more. Also, open database connections use system resources to a maximum extent making the system performance less effective. Why ADO.NET? To cope up with some of the problems mentioned above, ADO .NET came into existence. ADO .NET addresses the above mentioned problems by maintaining a disconnected database access model which means, when an application interacts with the database, the connection is opened to serve the request of the application and is closed as soon as the request is completed. Likewise, if a database is Updated, the connection is opened long enough to complete the Update operation and is

closed. By keeping connections open for only a minimum period of time, ADO .NET conserves system resources and provides maximum security for databases and also has less impact on system performance. Also, ADO .NET when interacting with the database uses XML and converts all the data into XML format for database related operations making them more efficient.

The ADO.NET Data Architecture Data Access in ADO.NET relies on two components: DataSet and Data Provider. DataSet The dataset is a disconnected, in-memory representation of data. It can be considered as a local copy of the relevant portions of the database. The DataSet is persisted in memory and the data in it can be manipulated and updated independent of the database. When the use of this DataSet is finished, changes can be made back to the central database for updating. The data in DataSet can be loaded from any valid data source like Microsoft SQL server database, an Oracle database or from a Microsoft Access database. Data Provider The Data Provider is responsible for providing and maintaining the connection to the database. A DataProvider is a set of related components that work together to provide data in an efficient and performance driven manner. The .NET Framework currently comes with two DataProviders: the SQL Data Provider which is designed only to work with Microsoft's SQL Server 7.0 or later and the OleDb DataProvider which allows us to connect to other types of databases like Access and Oracle. Each DataProvider consists of the following component classes: The Connection object which provides a connection to the The Command object which is used to execute a The DataReader object which provides a forward-only, read only, recordset The DataAdapter object which populates a disconnected DataSet with performs update database command connected data and

Data access with ADO.NET can be summarized as follows: A connection object establishes the connection for the application with the database. The command object provides direct execution of the command to the database. If the command returns more than a single value, the command object returns a DataReader to provide the data. Alternatively, the DataAdapter can be used to fill the Dataset object. The database can be updated using the command object or the DataAdapter.

Component classes that make up the Data Providers The Connection Object The Connection object creates the connection to the database. Microsoft Visual Studio .NET provides two types of Connection classes: the SqlConnection object, which is designed specifically to connect to Microsoft SQL Server 7.0 or later, and the OleDbConnection object, which can provide connections to a wide range of database types like Microsoft Access and Oracle. The Connection object contains all of the information required to open a connection to the database. The Command Object The Command object is represented by two corresponding classes: SqlCommand and OleDbCommand. Command objects are used to execute commands to a database

across a data connection. The Command objects can be used to execute stored procedures on the database, SQL commands, or return complete tables directly. Command objects provide three methods that are used to execute commands on the database: ExecuteNonQuery: Executes commands that have no return values such as INSERT, UPDATE or DELETE ExecuteScalar: Returns a single value from a database query ExecuteReader: Returns a result set by way of a DataReader object

The DataReader Object The DataReader object provides a forward-only, read-only, connected stream recordset from a database. Unlike other components of the Data Provider, DataReader objects cannot be directly instantiated. Rather, the DataReader is returned as the result of the Command object's ExecuteReader method. The SqlCommand.ExecuteReader method returns a SqlDataReader object, and the OleDbCommand.ExecuteReader method returns an OleDbDataReader object. The DataReader can provide rows of data directly to application logic when you do not need to keep the data cached in memory. Because only one row is in memory at a time, the DataReader provides the lowest overhead in terms of system performance but requires the exclusive use of an open Connection object for the lifetime of the DataReader. The DataAdapter Object The DataAdapter is the class at the core of ADO .NET's disconnected data access. It is essentially the middleman facilitating all communication between the database and a DataSet. The DataAdapter is used either to fill a DataTable or DataSet with data from the database with it's Fill method. After the memory-resident data has been manipulated, the DataAdapter can commit the changes to the database by calling the Update method. The DataAdapter provides four properties that represent database commands: SelectCommand InsertCommand DeleteCommand UpdateCommand When the Update method is called, changes in the DataSet are copied back to the database and the appropriate InsertCommand, DeleteCommand, or UpdateCommand is executed.

What is the .NET architecture?


Microsoft .NET consists of four major components:

Common Language Specification (CLS) - blue in the diagram below

Framework Class Library (FCL) - red Common Language Runtime (CLR) - green .NET Tools - yellow

At the base of the diagram in gray is the operating system, which technically can be any platform but typically is Microsoft Windows 2000 or greater, accessed through the Win32 API (Application Programming Interface).

Common Language Specification (CLS)


The CLS is a common platform that integrates code and components from multiple .NET programming languages. In other words, a .NET application can be written in multiple programming languages with no extra work by the developer (though converting code between languages can be tricky). .NET includes new object-oriented programming languages such as C#, Visual Basic .NET, J# (a Java clone) and Managed C++. These languages, plus other experimental languages like F#, all compile to the Common Language Specification and can work together in the same application.

Framework Class Library (FCL)


The FCL is a collection of over 7000 classes and data types that enable .NET applications to read and write files, access databases, process XML, display a graphical user interface, draw graphics, use Web services, etc. The FCL wraps much of the massive, complex Win32 API into more simple .NET objects that can be used by C# and other .NET programming languages.

Common Language Runtime (CLR)


The CLR is the execution engine for .NET applications and serves as the interface between .NET applications and the operating system. The CLR provides many services such as:

Loads and executes code Converts intermediate language to native machine code Separates processes and memory Manages memory and objects Enforces code and access security Handles exceptions Interfaces between managed code, COM objects, and DLLs Provides type-checking Provides code meta data (Reflection) Provides profiling, debugging, etc.

.NET Tools
Visual Studio .NET is Microsofts flagship tool for developing Windows software. Visual Studio provides an integrated development environment (IDE) for developers to create standalone Windows applications, interactive Web sites, Web applications, and Web services running on any platform that supports .NET. In addition, there are many .NET Framework tools designed to help developers create, configure, deploy, manage and secure .NET applications and components.

What is the history of .NET?


.NET started as a classic Microsoft FUD operation. In the late 1990s, Microsoft had just successfully fought off a frontal assault on its market dominance by killing the Netscape Web browser with its free Internet Explorer. But Microsoft was facing a host of new challenges, including serious problems with COM, C++, DLL hell, the Web as a platform, security, and strong competition from Java, which was emerging as the go-to language for Web development. Microsoft started building .NET in the late 90s under the name Next Generation Windows Services (NGWS). Bill Gates described .NET as Microsofts answer to the Phase 3 Internet environment, where the Internet becomes a platform in its own right, much like the PC has traditionally been Instead of a world where Internet users are limited

to reading information, largely one screen at a time, the Phase 3 Internet will unite multiple Web sites running on any device, and allow users to read, write and annotate them via speech, handwriting recognition and the like, Gates said. We are certainly approaching that vision. Microsoft announced .NET to the world in June 2000 and released version 1.0 of the .NET framework in January 2002. Microsoft also labeled everything .NET including briefly Office to demonstrate its commitment and dominance on this new thing called the Web. But out of that grand FUD campaign emerged the very capable and useful .NET development environment and framework for both the Web and Windows desktop.

What are the benefits of .NET?


.NET provides the best platform available today for delivering Windows software. .NET helps make software better, faster, cheaper, and more secure. .NET is not the only solution for developing Web software Java on Linux is a serious alternative. But on the Windows desktop, .NET rules. For developers, .NET provides an integrated set of tools for building Web software and services and Windows desktop applications. .NET supports multiple programming languages and Service Oriented Architectures (SOA). For companies, .NET provides a stable, scalable and secure environment for software development. .NET can lower costs by speeding development and connecting systems, increase sales by giving employees access to the tools and information they need, and connect your business to customers, suppliers and partners. For end-users, .NET results in software thats more reliable and secure and works on multiple devices including laptops, Smartphones and Pocket PCs.

Why are you (this blog author) developing in .NET?


The Mini-Tools developers were impressed with the Microsoft .NET technology and development platform and felt it provided the best environment with which to build and deliver innovative desktop and Web software for Windows. All of our software is written in C# for .NET on Windows.

Why should I install .NET on my computer?


Because many new software applications require .NET. Having the latest version already installed on your computer enables you run new .NET applications immediately as they become available.

Which versions of .NET are available?


The newest version available today is NET v3.0, but most PC users have v2.0 installed. Although .NET v3.0 is now available, Windows Update is not automatically installing it, hence few people have it. People who purchase new PCs with Windows Vista pre-installed will receive the latest .NET v3.0 but there may be some versioning issues. Microsoft released a beta version of .NET v3.5 in April 2007. Following are the production versions of .NET: Version Name Version Number 1.0 1.0 SP1 1.0 SP2 1.0 SP3 1.1 1.1 SP1 2.0 3.0 1.0.3705.0 1.0.3705.209 1.0.3705.288 1.1.4322.573 2.0.50727.42 3.0.4506.30 Release Date 2002-01-05 2002-03-19 2002-08-07 2003-04-01 2005-11-07 2006-11-06

1.0.3705.6018 2004-08-31 1.1.4322.2032 2004-08-30

How do I know if I already have .NET?


We have queried your Web browser, and it tells us that you have the following .NET versions installed on your PC (note this only works for Internet Explorer): Another way to check if you have .NET: 1. 2. 3. 4. Click Start on your Windows desktop. Select Control Panel. Double-click Add or Remove Programs. When the Add/Remove window appears, scroll through the list of applications and try to find Microsoft .NET Framework. There you will see which versions of .NET are installed on your PC.

Where can I get .NET?


Microsoft .NET is available as a FREE download from Microsoft.

Why is .NET separate from the Windows operating system?


Another way to ask this question is, Why doesnt Microsoft ensure every Windows PC has the latest version of .NET installed? Since .NET is so important to Windows, and Microsoft delivers both .NET and Windows, why doesnt Microsoft simply make .NET part of Windows? Just my theory, but it probably stems from the Sun vs. Microsoft bad blood over Java. Sun and Microsoft got into a legal spat, Microsoft stopped shipping Java with Windows, and so now Java is a separate download for Windows users. As a result, perhaps Microsoft is wary of appearing monopolistic, hence they maintain the .NET Framework as a separate download too. Why is this a problem? Because it is a large file that must be downloaded and installed separately, naturally many people view .NET with suspicion or at least hesitation. And this provides an inconvenience and yet another barrier for a potential customer purchasing our .NET software. So heres my plea: Microsoft, please include the latest version of .NET as an automatic download to every Windows PC as part of the normal Windows Update process. Thank you.

Will .NET cause problems on my computer?


No. Once .NET is installed, you do not have to do anything to manage it, and .NET should not adversely affect the operation of your computer.

What should I do now?


Download and install the latest version of .NET! :-)

Links

Download .NET .NET FAQ .NET Developer Center .NET Basics .NET in Wikipedia .NET vs. Java What Is .NET (Or, How I Learned to Stop Worrying and Love the Runtime)

ShareThis Related posts: 1. 2. 3. 4. 5. FAT .NET Visual Studio 2008 and .NET 3.5 Released Visual Studio "Orcas" and .NET 3.5 Beta Available Windows SDK for Windows 7 and .NET Framework 3.5 SP1: RC Microsoft to Share .NET Framework Code

Tags: .NET, Bill-Gates, CLS, Common-Language-Specification, FCL, Framework-Class-Library, Microsoft, Microsoft-.NET, Visual Studio, Visual-Studio-.NET, Windows

25 Responses to What is .NET?


1. FLYabroad Says:
February 28th, 2008 at 5:32 am

good tks!

Introduction to Microsoft's .NET Platform



Comments (2) PDF 1 interested

By Nakul Goyal, published on 01 Jul 2003


Page 1 of 3

Introduction
In the present Internet scenario, accessing data from different accounts at various places isn't practically feasible. Usually databases are designed for particular devices such as a PC, a WAP enabled Cell Phone, a PDA (HPC) is inaccessible from other devices. Microsoft has unveiled Microsoft .NET which supports the following technologies keeping all these aspects in mind.

ASP.NET

C#

VS.NET

VB.NET

ADO.NET

XML Web Services

Jscript.NET

VISUAL J#.NET

SOAP & UDDI

VISUAL C#.NET

These are some of the terms that all software developers & jobseekers have been having their eyes glued on since at least early last year. This article is devoted to those who need to or love to keep themselves updated with the emerging trends of technology

What is .NET ? Since quite some time each person is talking about .NET, but what actually is .NET ? In this Article i will explain you the meaning and the advantages of .NET. The .NET Framework introduces a completely new model for the programming and deployment of applications. .NET is Microsoft's vision of "software as a service", a development environment in which you can build, create, and deploy your applications and the next generation of components, the ability to use the Web rather than your own computer for various services. Microsoft introduced great technologies like COM, DCOM, COM+ etc. to enable reuse of Software. Although these technologies are very powerful to reuse Software, they required a huge learning curve. According to this aspect, Microsoft realized that its time to come up with a new Technology, a better one, an easier one, a new Framework, within which each Programming Task is easy accomplished. The .NET Framework was born:

Microsoft changed all complex tasks with the new .NET Framework. That was a huge advantage for all developers. Most of the Win32 API was now accessible through a very simple Object Model. Most of the features and functions of C++ were added to Visual Basic. A new Programming Language C# was introduced, which offered flexibility and productivity. ASP.NET also called ASP+ replaced ASP. It provides the easiest and most scalable way to build, deploy and run web services . ASP.NET server controls enable an HTML-like style of declarative programming that let you build great pages with far less code than with classic ASP. VB, C++ and C# Code can be used in other languages f.e. code written in VB can be easily used in C# or in VC++. Also an another benefit is that the you can step between the languages in the debugger. The .NET Compilation Stages: The Code written in .NET isn't compiled directly to the executable, instead .NET uses two steps to compile the code. First, the code is compiled to an Intermediate Language called Microsoft Intermediate Language (MSIL). Second, the compiled code will be recompiled with the Common Language Runtime ( CLR ), which converts the code to the machine code. The basic Idea of this two stages was to make the code language independence. The major Components ( Layers ) of the .NET framework: The top layer includes user and program interfaces. Windows Forms are a new way to create standard Win32 desktop applications, based on the Windows Foundation Classes (WFC) produced for J++. Web Forms provide a powerful, forms-based UI for the web. Web Services, which are perhaps the most revolutionary, provide a mechanism for programs to communicate over the Internet using SOAP. Web Services provide an analog of COM and DCOM for object brokering and interfacing, but based on Internet technologies so that allowance is made for integration even with non-Microsoft platforms. Web Forms and Web Services, comprise the Internet interface portion of .NET, and are implemented through a section of the .NET Framework referred to as ASP.NET. The middle layer includes the next generation of standard system services such as ADO.NET and XML. These services are brought under the control of the framework, making them universally available and standardizing their usage across languages. The last layer includes system-level capability that a developer would need.

S-ar putea să vă placă și