0

We want to troll our teacher, we want to start a new console window when he inputs something (arbitrary value) invalid.

Is there a way that we could start a new console window from Main?

using System;
using System.Diagnostics;

static void Main(string args)
{
    Process.Start();
}
Jaacko Torus
  • 796
  • 7
  • 24
  • 1
    It's duplicated. Check this https://stackoverflow.com/questions/3379022/open-two-console-windows-from-c-sharp/27912557 or this https://stackoverflow.com/questions/697227/is-there-a-way-to-create-a-second-console-to-output-to-in-net-when-writing-a-co – Ignasi93 Dec 09 '19 at 14:28
  • [`Process.Start()`](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.start?view=netframework-4.8) with `cmd.exe` – 001 Dec 09 '19 at 14:28
  • @JohnnyMopp We tried running it and we get an error `"error CS0120: An object reference is required for the non-static field, method, or property 'Process.Start()' [C:\Users\Julian\Desktop\Bellecour\c#\191205 - HW\191205 - HW.csproj]"` – Jaacko Torus Dec 09 '19 at 14:29
  • 1
    @JaackoTorus Please [edit] and add your code. – 001 Dec 09 '19 at 14:30
  • 1
    @JaackoTorus You forgot the parameter: `Process.Start("cmd.exe");` – 001 Dec 09 '19 at 14:32

1 Answers1

2

Sure ;)

System.Diagnostics.Process.Start("CMD.exe");
VillageTech
  • 1,968
  • 8
  • 18
  • 1
    Thank you, we are beginners, and we couldn't decipher the other answers! – Jaacko Torus Dec 09 '19 at 14:32
  • 1
    EDIT: NVM, I'm dumb, I figured it out ;) thanks for the help Hey sorry to bother you again, but we just tried this and it doesn't add a new console window, instead it prints `(c) 2019 Microsoft Corporation. All rights reserved.` and then a new line – Jaacko Torus Dec 09 '19 at 14:40