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

  • Thread starter Thread starter Marc Gravell
  • Start date Start date
M

Marc Gravell

How about:

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

and:
csc my.cs

That seems to fit the bill...?
 
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
 
Kee said:
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.GetCommandLineArgs() [1]);
System.Console.WriteLine("Hello world");
System.Console.Error.WriteLine("Hello, stderr");
string input = System.Console.In.ReadLine();
}
}
 
Marc said:
How about:

class Program {
static void Main() {
System.Console.WriteLine("Hello 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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top