Skip to content

Instantly share code, notes, and snippets.

@nisar1
Created April 1, 2014 09:59

Revisions

  1. nisar1 renamed this gist Apr 1, 2014. 1 changed file with 0 additions and 0 deletions.
  2. nisar1 created this gist Apr 1, 2014.
    51 changes: 51 additions & 0 deletions argment in console application
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    //argment in console application

    //1. first you need to use third party dll or code
    // NDesk.Options

    //2. second you can use it as



    using System;
    using NDesk.Options;
    namespace txtProcessorConsole
    {
    class Program
    {
    public static void Main(string[] args)
    {
    string smachine = "";
    string sip = "";
    int iport = 5005;
    int ipass = 0;
    string sxportPath = "";

    var p = new OptionSet() {
    { "m|machine=", "the name of the {machine} ",
    (string v) => smachine = v },
    { "i|ip=", "the address of the {ip} ",
    (string v) => sip = v },
    { "p|port=", "the address of the {ip} ",
    (int v) => iport = v },
    { "P|Pass=", "the address of the {ip} ",
    (int v) => ipass = v },
    { "e|export=", "the address of the {ip} ",
    (string v) => sxportPath = v },
    };
    try
    {
    p.Parse(args);
    }
    catch (OptionException e)
    {
    Console.Write("greet: ");
    Console.WriteLine(e.Message);
    return;
    }
    Console.WriteLine(smachine + " " + sip + " " + iport + " " + ipass + " " + sxportPath);
    }
    }
    }