开发者

C#/Mono Console.In.ReadToEnd() stopping process

If I have the following code:

namespace foo {
 public class FooClass {
  public static void Main (string[] argsRaw) {
   Console.WriteLine(Console.In.ReadToEnd());
  }
 }
}
开发者_如何学Go

And I run it, process will stop once the end of the stream is reached.

Output:

(Text of my input stream)
[1]+  Stopped                 bin/Debug/foo.exe

How do I get my program to behave more like grep, which does not stop after hitting EOF?


I figured it out.

You need to make sure that Main's return type is an int.

namespace foo {
    public class FooClass {
        public static int Main (string[] argsRaw) {
            Console.WriteLine(Console.In.ReadToEnd());
            return 0;
        }
    }
}

Works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜