anybody hold a sample of C# project for design a console based application?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kee

    anybody hold a sample of C# project for design a console based application?

    Dear All

    I need a sample working under console using C#, basically it should
    looks like utilities under console support pipe and redirect operation.

    May I seek your help to send me a completed project/library sample of
    that pls?


    Regards


    Kee
  • Marc Gravell

    #2
    Re: anybody hold a sample of C# project for design a console basedapplicatio n?

    How about:

    class Program {
    static void Main() {
    System.Console. WriteLine("Hell o world");
    }
    }

    and:
    csc my.cs

    That seems to fit the bill...?

    Comment

    • Kee

      #3
      Re: anybody hold a sample of C# project for design a console basedapplicatio n?

      Marc Gravell wrote:
      How about:
      >
      class Program {
      static void Main() {
      System.Console. WriteLine("Hell o world");
      }
      }
      >
      and:
      csc my.cs
      >
      That seems to fit the bill...?
      Hi Marc

      Thanks for your class sample, however, it is a bit beyond what I needs ,
      it is partly because I need the application working in cygwin enviroment
      and co-work with unix utility.

      So, a command option parser and a class adapter with the basic "stdin"
      "stdout" and "stderr" is prefered.


      Kee

      Comment

      • Family Tree Mike

        #4
        Re: anybody hold a sample of C# project for design a console based application?


        "Kee" <keekychen@gmai l.comwrote in message
        news:gb23qg$lqd $1@news.cn99.co m...
        Marc Gravell wrote:
        >How about:
        >>
        >class Program {
        > static void Main() {
        > System.Console. WriteLine("Hell o world");
        > }
        >}
        >>
        >and:
        >csc my.cs
        >>
        >That seems to fit the bill...?
        >
        Hi Marc
        >
        Thanks for your class sample, however, it is a bit beyond what I needs ,
        it is partly because I need the application working in cygwin enviroment
        and co-work with unix utility.
        >
        So, a command option parser and a class adapter with the basic "stdin"
        "stdout" and "stderr" is prefered.
        >
        >
        Kee
        Without knowing what command parsing means to you, here is an expanded
        example using stdin, stdout and stderr. Of course you should check the
        argument count before using it.

        class Program {
        static void Main() {
        System.Console. Out.WriteLine(" Arg [1]: " +
        Environment.Get CommandLineArgs () [1]);
        System.Console. WriteLine("Hell o world");
        System.Console. Error.WriteLine ("Hello, stderr");
        string input = System.Console. In.ReadLine();
        }
        }

        Comment

        • Marc Gravell

          #5
          Re: anybody hold a sample of C# project for design a console basedapplicatio n?

          As "Family Tree Mike" notes, System.Console *is* a wrapper for stdin,
          stdout and stderr, and as-such has full support for any redirection
          offered to those pipes by the host OS. In the lack of any more
          detailed requirements, writing "Hello World" to stdout seemed a
          sensible starter...

          Marc

          Comment

          Working...