suresh

suresh

  • NA
  • 55
  • 0

Command Line Arguments

Feb 29 2012 7:50 PM
Hi, 
I have 3 class files.

namespace M
{
    class Add
    {
        static void Main(string[] args)
        {
          Add();
        }
    Public static void Add()
    {
     int a=10;
     int b=10;
     int c=a+b;
    }
    }
}

namespace N
{
    class Mul
    {
        static void Main(string[] args)
        {
          Mul();
        }
    Public static void Mul()
    {
     int a=10;
     int b=10;
     int c=a*b;
    }
    }
}

namespace P
{
    class Mul
    {
        static void Main(string[] args)
        {
          Sub();
        }
    Public static void Sub()
    {
     int a=10;
     int b=10;
     int c=a-b;
    }
    }
}

Above three class file i have to use in another class file i.e

Here i need to pass Arguments using Command Line, so how to pass arguments to the below class.
If i pass argument /add then first case statement to be executed.
If i pass argument /Multhen second case statement to be executed.
If i pass argument /Sub then third case statement to be executed.

namespace Maths
{
    class Mathematics
    {
        static void Main(string[] args)
        {
          foreach(string str in args)
          {
           GetAllTasks(str);
          }
        }
    Public static void GetAllTasks(string str)
    {
     switch(args)
     {
      case "/add":
      "Here i need to execute the First Class Method ADD()"
      case "/Mul":
      "Here i need to execute the Second Class Method Mul()"
      case "/sub":
      "Here i need to excute the third class method Sub()"
      break;
     }
    }
    }
}
Please help me....

Answers (2)