Thursday, February 27, 2014

Execute .NET Application in Command Windows

Executing .NET Applications from Command Window:

  • Sometimes,  you  may  require  running  the  .NET applications  from  Command  window (MS-DOS window).
  • At that time, follow the below steps:
  • Click on ―> Start ―> Run.
  • Type ―> cmd.
  • Press Enter.
  • A MS-DOS prompt window will be opened.
Console application
  • Now,  locate  the  ―bin‖  folder  of  the  required  application,  by  using  the  following commands.  For  example,  let  us  imagine  that  there  is  a  project  named ConsoleApplication1 in "D:" drive.
console  application

Passing Arguments to Main() Method

  • All of the previous examples in the material have been given without any arguments to the Main() method.
  • However, when the program is invoked, you can pass some arguments to the Main() method, if required.
  • C#‘s  Main()  method  receives  those  arguments  in  string  array  format,  traditionally called as "args" (of course, C# allows you change the name also).
  • Syn: Main(string[] args)
  • Those arguments could be called as ―Command line arguments‖.
  • You can use these command line arguments for the internal logic in the application
passing argument to main method

Download above code  of Demo on Main() Method Arguments : Downloads Links