Sie sind auf Seite 1von 5

Deccansoft Software Services - MS.NET C# Agenda: VS.NET and Entry Point Method - Main About Visual Studio.NET VS.

.NET VS.NET Editions Developing First .NET Application Entry Point Method Main Importance of Command Line Arguments Resolving Entry Point Main Ambiguity Using Command Line Compiler CSC.EXE

VS.NET and Entry Point Method - Main

About Visual Studio.NET (VS.NET) 1. Its an IDE (Integrated Development Environment) and RAD (Rapid Application Development) Tool o o o o o o o o 2. Code Editor Intellisense Code refactoring Debugger Forms Designer Web Designer Database Schema Designer Class Designer

It can be extended with plug-ins that enhance the functionality at any level. o o o Macros, add-ins and packages Eg: Source Control like Visual Source Safe Team Foundation Server support

3.

Languages Supported o o o C#, VB.NET, VC++.NET, J# & F# (by Microsoft) Other languages such as PHP, Python, Ruby HTML, XML, CSS and Javascript

4.

Can be used for developing all types of applications VS.NET 2012 Editions

Express Edition o o o Its Free Ideal for learning MS.NET Different IDE for developing Desktop and Web Applications

Professional Edition o o o Available in 90 days trial Best for small team of software development Supports extensive tools for app development and debugging

Deccansoft Software Services - MS.NET C# o Supports Unit Testing Premium Edition o o o o o Everything what Professional Edition Supports Supports Agile Project Management Tools Test Case Management and Exploratory Testing Peer code review to improve code quality Automated UI Testing

VS.NET and Entry Point Method - Main

Ultimate Edition o o o o o Everything what Premium Edition Supports Understand Code dependencies through Visualization Visualization of impact of code changes Performing Unlimited Web Performance and Load testing Design architectural layer diagrams.

For complete list of features and their videos, Please visit: http://www.microsoft.com/visualstudio/eng/products/compare

To download the software: Please visit: http://www.microsoft.com/visualstudio/eng/downloads

Developing Your First .NET Application Project Structure: 1. Solution is a Collection of Projects. One Solution can have many projects and every project added to the solution can of same language or different languages. 2. 3. The Solution file has the extension .sln (ApplicationName.sln). A Project is a collection of files including Source Code(.cs), Resources(.resx), Configuration(.config) files etc 4. 5. The project file has the extension .csproj A project when Build (compilation + linking) generates an EXE/DLL as output, which is called as PE.

First MS.Net Application: Goto File New Project Select Visual C# on Left and Console Application on right. Name = HelloWorldDemoApp This is the project name Location = D:\Demos\. class Program { public static void Main()

Deccansoft Software Services - MS.NET C# { Console.WriteLine("Hello World"); } }

VS.NET and Entry Point Method - Main

To Build the Solution Goto Menu: Build Build Solution (Ctrl + Shift + B) To Run the Application 1. 2. Debug Start Debugging (F5) Here we can use break points and debug the application. Debug Start Without Debuggin (Ctrl + F5) - We can see the output in console window.

When the project is build the following output file is generated: Drive:\...\<ProjectName>\bin\debug\<ProjectName>.Exe Note: In VS.NET, at the time of creating a project we can specify the Framework Version to be used which can be either 2.0, 3.0, 3.5, 4.0 or 4.5.

Importance of Command Line Arguments Mostly the console based applications are developed in situations where the application should either run as a top level process or as child process (invoked from another parent process).

Commandline Arguments: This is the best way of providing input to the console based application. using System; class Program { static void Main(string[] args) //args is an array of strings - Command line arguments. { Console.WriteLine("Hello " + args[0]); //args(0) is the first command line argument. } } To specifiy Command Line Arguments: View Solution Explorer Select Project Right Click Properties Debug Tab Command Line Arguments Provide string separated by space (Args1 Args2 Args3) Or Give at command prompt in console window Drive:\. . . \ ProjectName\bin\debug\<ProjectName>.exe Args1 Args2 Args3

Deccansoft Software Services - MS.NET C#

VS.NET and Entry Point Method - Main

Significance of Return value of Main using System; class Program { static int Main(string[] args) { Console.WriteLine("Hello " + args[0]); return 0; } } 1. When the application is not used as child process, the return value of main is not usefull because what ever may return the value when Main method ends the application terminates and OS will clean all the memory allocated to it. 2. The return value of Main is used by the terminating application to communicate its state to the parent process if any. The Integer return value can be predefined with some meaning and the same will be used by the parent process to know the state of child process which terminated. 3. The return value of Main is called as EXIT CODE of the application.

Resolving Main ambiguity One Project can have multiple modules but only one of many modules with valid Main can be treated as Startup or Entry Point of the application. To Add another File to Project: Goto Solution Explorer Right Click on Project Add Class using System; class Program2 { static void Main() { Console.WriteLine("Hello Program2"); } } To Set Startup Object: View Solution Explorer Project Right Click Properties Application Tab Starup Object Select Class whose Main should be used as entry point.

Note: The class declared as startup object cannot have more that one form of Main which are valid for entry point.

Deccansoft Software Services - MS.NET C# VS.NET and Entry Point Method - Main All classes in the project can be placed in either in same file or in different files. In either case the compiler is going to compile them together. i.e. for a dotnet language compiler files cannot be used as boundries and all the files are compiled together as one unit.

To Open a closed Solution / Project: File Open Project / Solution Give the Path of .sln file.

Using Command line Compiler (CSC.EXE) To develop an application without using VS.NET 1. 2. 3. Open Notepad Write the code as given above and Save as C:\Demo.CS Goto Start Programs Microsoft Visual Studio 2008 Visual Studio Tools VS 2008 Command Prompt (so that the directory of MS.NET Framework is set in PATH) 4. 5. CSC.EXE C:\Demo.CS => Generates Demo.exe Run Demo.exe

Framework Folder: C:\Windows\Microsoft.Net\Framwork\VX.X.XXXX\

Das könnte Ihnen auch gefallen