Agenda: VS.NET and Entry Point Method - Main
- About Visual Studio.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
About Visual Studio.NET 2015 (VS.NET)
1.It’s an IDE (Integrated Development Environment) and RAD (Rapid Application Development) Tool
- Code Editor
- Intellisense
- Code refactoring
- Debugger
- Forms Designer
- Web Designer
- Database Schema Designer
- Class Designer
- Macros, add-ins and packages
- Eg: Source Control like Visual Source Safe
- Team Foundation Server support
- C#, VB.NET, VC++.NET, J# & F# (by Microsoft)
- Other languages such as PHP, Python, Ruby
- HTML, XML, CSS and Javascript
Community Edition
- Free for open source projects, academic research, training, education and small professional teams
- Ideal for learning MS.NET
- Full featured IDE for developing Desktop and Web Applications.
- Also for building cross platform iOS, Android and Windows App.
Professional Edition
- Best for small team of software development as it has professional developer tools for building any type of application.
- Powerful features to improve your team's productivity such as CodeLens
- Improve team collaboration with Agile project planning tools, Team Rooms, charts andmore
- Supports extensive tools for app development and debugging.
- Supports Unit Testing.
Enterprise Edition
- Everything what Professional Edition Supports
- Build quality applications at scale with advanced features such as Load Testing, automatedand manual testing and new IntelliTest capabilities
- Manage complexity and resolve issues quickly with features such as Code Map andIntelliTrace
class Program
MS.NET – C# VS.NET and Entry Point Method - Main
1 2 3 4 5 6 7 8 |
using System; class Program { public static void Main() { Console.WriteLine("Hello World"); } } |
To Build the Solution Goto Menu: Build Build Solution (Ctrl + Shift + B)
To Run the Application
1. Debug => Start Debugging (F5) – Here we can use break points and debug the application.
2. 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:\...\\bin\debug\.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). This is the best way of providing input to the console based application.
1 2 3 4 5 6 7 8 |
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\.exe Args1 Args2 Args3 Significance of Return value of Main MS.NET – C# VS.NET and Entry Point Method - Main 5
1 2 3 4 5 6 7 8 9 |
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 ambiguity of Main method
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
1 2 3 4 5 6 7 |
class Program2 { static void Main() { Console.WriteLine("Hello Program2"); } } |
To Set Startup Object: View => Solution Explorer => Project => Right Click => Properties => Application Tab
=> Startup 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.