|
Last Modified 5-1-2010 |
IUSB |
|||||||||||||||||||||||||||||
|
Home C# Introduction to C# .NET FrameworkVS2008 IDE How C# is Compiled Start Visual Studio Windows Form App C# Code Example C# Coding Rules RecommendationsError Window C# Comments C# Help Window Language Essentials C# Data Types Declare Variables Declare Constants Arith. Expressions Assign Statements Operator Precedence Type CastingMath Class C# Strings String Esc Sequences Convert Data Types ToString Formatting Variable Scope UseC# Enumeration Use C# Nullable Types Program #2 C# Code Control Relational OperatorsLogical Operators If-Else Statement Switch Statement |
C# Programming IntroductionYou can use Visual Studio for developing the two types of applications:
The .NET FrameworkA more detailed view of the .NET Framework is given in Figure CS-1:
Description
As you can see, the .NET Framework provides a common set of services that application programs written in a .NET language such as C# can use to run on various operating systems and hardware platforms. The .NET Framework is divided into two main components:
The .NET Framework Class Library consists of segments of pre-written code called classes that provide many of the functions that you need for developing .NET applications. For instance, the Windows Forms that you need for developing .NET applications. For instance, the Windows Forms classes are used for developing Windows Forms applications. The ASP.NET classes are used for developing Web Forms applications. And other classes let you work with databases, manage security, access files, and perform many other functions. Although it's not apparent in this figure, the classes in the .NET Framework Class Library are organized in a hierarchical structure. Within this structure, related classes are organized into groups called namespaces. Each namespace contains the classes used to support a particular function. For example, the System.Windows.Forms namespace contains the classes you use to access data. Visual Studio Integrated Development Environment IDE
Figure CS-2 shows the Microsoft Visual Studio Integrated Development Environment. In practice, this IDE if often referred to as Visual Studio. Microsoft Visual Studio supports 3 languages: Visual Basic, Visual C#, and Visual C++. Microsoft Visual Studio includes designers that can be used to design the user interface for Windows Forms and Web Forms applications. The visual tools make this tough task much easier. You'll be introduced to the designer for Windows Forms. Visual Studio also includes an editor that can be used to work with any of the three languages presented in Figure CS-1 as well as HTML and XML. This editor contains many features that make it easy to enter and edit the code for an application. Description
How A C# Application is compiled and Run
Figure CS-3 shows how a C# program is compiled and run. To start, you use Visual Studio to create a project, which is made up of source files that contain C# statements. A project may also contain other types of files, such as sound, image or text files. After you enter the C# code for a project, you use the C# Compiler, which is built into Visual Studio, to build or compile your C# source code into Microsoft Intermediate Language. At this point, the Intermediate Language is stored on disk in a file that's called an assembly. In addition to the Intermediate Language, the assembly includes references to the classes that the application requires. The assembly can then be run on any PC that has the Common Language Runtime installed on it. When the assembly is run, the Common Language Runtime converts the Intermediate Language to native code that can be run by the Windows operating system. If you have developed applications with other languages, this process should be familiar to you. If this is your first language, though, you will not really understand this process until you develop your first applications. Incidentally, a solution is a container that can hold one or more projects. Although a solution can contain more than one project, the solution for a simple application usually contains just one project. In that case, the solution and the project are essentially the same thing. Operation
How C# differs from the other .NET languagesC# uses the same .NET Framework classes as the other .NET programming languages. These classes affect almost every aspect of programming, including creating and working with forms and controls, using databases, and working with basic language features such as arrays and strings. In addition, C# works has many similarities to the other .NET languages. The main difference is the syntax of the language. How C# differs from JavaThe C# language uses a syntax that's similar to the syntax for the Java language. However, Java relies on a different framework of supporting classes and the development environments for working with Java are different than Visual Studio. As a result, if you have experience with Java, it should be easy for you to learn the C# language. However, if Visual Studio and the .NET Framework classes are new to you, it may take some time to learn how they work. A Tour of the Visual Studio Integrated Development EnvironmentWith all that as background, we're ready to take a tour of the Visual Studio IDE. Along the way, we'll touch on some basic techniques for working in this environment. We'll also go over how some of the terms we just went over are applied within the Integrated Development Environment. How To Start Visual StudioSelect Start → All Programs from your Windows main screen as indicated in the diagram below:
All programs will display a list of Program folders:
When the Visual Studio program starts the Start Screen should look similar to the diagram below:
|
|