467,912 Members | 1,559 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,912 developers. It's quick & easy.

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

Kee
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
Sep 19 '08 #1
  • viewed: 1532
Share:
4 Replies
How about:

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

and:
csc my.cs

That seems to fit the bill...?
Sep 19 '08 #2
Kee
Marc Gravell wrote:
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
Sep 20 '08 #3

"Kee" <ke*******@gmail.comwrote in message
news:gb**********@news.cn99.com...
Marc Gravell wrote:
>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
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();
}
}

Sep 20 '08 #4
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
Sep 21 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Scott Haner via DotNetMonster.com | last post: by
reply views Thread by thjwong | last post: by
3 posts views Thread by Ubergeek | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.