340 likes | 351 Views
Learn to develop applications using Visual Studio 2005 and C# with an overview of software engineering, .NET Framework, and object-oriented programming concepts.
E N D
Emerging Computing Unit-3: Introduction to MS Visual Studio and C# M. Abu Baker Siddique
Course Outlines • Introduction to problem solving • Introduction to software engineering • Overview of .NET Framework & Methods • Overview of Visual Studio 2005 • Introduction to C# • Classes & OOP • Software Requirements • Requirements Engineering Processes • Rapid Application Development • Forms & Controls • Software Testing • Verification and validation
Visual Studio • Visual Studio 2005 (VS 2005) is an integrated IDE enabling development of C++, C#, and Visual Basic and J #applications under one roof • It includes numerous features that help in building windows applications with less effort • First, let's start our VS.Net 2005 IDE
Hello World application. • Click 'File > New > Project' from the menu bar. • The following dialog box will appear.
Hello World application. • For this course, projects must be implemented as a C# application. To start building a C# Console Application follow the following steps. O • n the category column on the left select 'Visual C# > Windows'. Next, choose 'Console Application' and type 'IntroApp' as your project name. • Also, choose a location to save your application
Hello World application. • Click 'OK'. Another dialog will appear. • One can specify additional settings through this dialog, however for this simple application simply accept the default settings by clicking 'Finish'
Hello World application. • An application developed in VS.Net 2005 is organized into a hierarchy: solution, project and files. • A solution contains one or more project(s); • a project contains one or more file(s). Most files are either source files (.cs) or other reference files. • Double-click the main source file of our IntroApp project (i.e. Program.cs) in the Solution Explorer to view its content in the Code Editing window.
Hello World application. • To build the application press F6, alternatively click the Build Solution () toolbar. • To run the application press F5, alternatively click the Start toolbar (). • When the application is run, the following console will appear.
Introduction to C# • C# is a : • Simple • Modern • general-purpose, • object-oriented programming language developed by Microsoft within its .NET initiative led by Anders Hejlsberg.
Hello World Application using System; class HelloWorld { static void Main( ) { /* my first program in C# */ Console.WriteLine("Hello World"); Console.ReadKey(); } } }
C# - Overview • C# is a : • Simple • Modern • general-purpose, • object-oriented • Developed by Microsoft • Approved by European Computer Manufacturers Association (ECMA) and International Standards Organization (ISO).
C# - Overview • C# was developed by Anders Hejlsberg and his team during the development of .NetFramework • C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows use of various high-level languages on different computer platforms and architectures.
C# - Overview • The following reasons make C# a widely used professional language: • It is a modern, general-purpose programming language • It is object oriented. • It is easy to learn. • It is a structured language. • It produces efficient programs. • It can be compiled on a variety of computer platforms. • It is a part of .Net Framework.
C# - Program Structure • Creating Hello World Program, a C# program consists of the following parts: • Namespace declaration • A class • Class methods • Class attributes • A Main method • Statements and Expressions • Comments
Hello World Application using System; class HelloWorld { static void Main( ) { /* my first program in C# */ Console.WriteLine("Hello World"); Console.ReadKey(); } }
C# - Program Structure • When this code is compiled and executed, it produces the following result: Hello World
C# - Program Structure • The first line of the program using System; - the using keyword is used to include the System namespace in the program. A program generally has multiple using statements. • In general, a namespace uniquely identifies a set of names so that there is no ambiguity when objects having different origins but the same names are mixed together
C# - Program Structure System.Console.WriteLine("Hello World!"); • System is a namespace and Console is a class in that namespace. • Theusing keyword can be used so that the complete name is not required, as in the following example: using System;
C# - Program Structure • The next line has a class declaration, the class Hello World contains the data and method definitions that your program uses. Classes generally contain multiple methods. • Methods define the behavior of the class. • However, the Hello World class has only one method Main.
C# - Program Structure • The next line defines the Main method, which is the entry point for all C# programs. • TheMain method states what the class does when executed.
C# - Program Structure • The next line defines the Main method, which is the entry point for all C# programs. • TheMain method states what the class does when executed.
C# - Program Structure • The next line /*...*/ is ignored by the compiler and it is put to add comments in the program
C# - Program Structure • The next line /*...*/ is ignored by the compiler and it is put to add comments in the program
C# - Program Structure • The Main method specifies its behavior with the statement Console.WriteLine("Hello World"); • WriteLine is a method of the Console class defined in the System namespace. • This statement causes the message "Hello, World!" to be displayed on the screen.
C# - Program Structure • The last line Console.ReadKey(); is for the VS.NET Users. • This makes the program wait for a key press and it prevents the screen from running and closing quickly when the program is launched from Visual Studio .NET
C# - Program Structure • Important Note • C# is case sensitive. • All statements and expression must end with a semicolon (;). • The program execution starts at the Main method. • Unlike Java, program file name could be different from the class name.