简体   繁体   中英

How to compile & execute text in c#?

I am working on an operating system with Cosmos, I am wondering if there is a way to compile text from a file, for example: helloworld.cs, and then execute the file. Thanks in advance.

If you want to compile a c# file (.cs) like helloworld.cs in Windows

namespace test {
    class test {
        static void Main(string[] args) {
            System.Console.WriteLine("Hello World");
        }
    }

}

you can use csc.exe to compile the file

C:\Windows\Microsoft.NET\Framework\{version}\csc.exe pathToFile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM