我不知道是否有某種方法來執行字符串,或將其轉換爲代碼,例如: 「Console.WriteLine(\」Hello \「)」;執行一個字符串作爲代碼
等效於JavaScript中的'eval'。
我翻譯了谷歌翻譯。
我不知道是否有某種方法來執行字符串,或將其轉換爲代碼,例如: 「Console.WriteLine(\」Hello \「)」;執行一個字符串作爲代碼
等效於JavaScript中的'eval'。
我翻譯了谷歌翻譯。
更做作一下,然後用一些語言eval
,but it is certainly possible to programmatically compile code。
您可以嘗試cshell:http://cshell.net/
它有一個基於repl的並執行c#代碼。
我還沒有嘗試過自己,但似乎你在找什麼是使用羅斯林(.NET編譯服務)
看看eval()-like for C# using Roslyn and ScriptCS和Hosted Execution of smaller code snippets with Roslyn
旁註容易可行的:有一個葡萄牙語版本的堆棧溢出:http://pt.stackoverflow.com/ –
可能重複[如何動態讀取C#類的屬性?](http://stackoverflow.com/questions/4629/how-can- i-read-the-ac-sharp-class-properties的屬性) –
http://stackoverflow.com/questions/12964790/using-c-sharp-as-my-dsl-is-this-在這種情況下,ChristopheD的答案(如下)是最好的。 – philologon