【解決方法】名前空間 ‘rextester’ のクラス ‘program’ のエントリ メソッド ‘main’ が見つかりません

プログラミングQA


こんにちは、私たちは仕事のトレーニング要素で C# について少し学んでおり、C# が何をし、すべてがどのように機能するかを理解するためにこのコードを提供してくれました。 Rextester というオンライン コンパイラでコンパイルしようとしましたが、このエラーのために動作しませんでした。 誰かが私を導き、私が何をすべきかを教えてくれますか? 私はプログラミングについて何も知らないので、この全体が台無しになっている場合はご容赦ください
これがコードです

using System;
using System.Collections.Generic;
namespace Rextester
{
class Program
{
    static void Main(String[] args)
    {System.Console.WriteLine(args.Length);
    }
        static List<string> Loader(){
        List<string> load = new List<string>();
        for(int j = 0; j < 10; j++){
            load.Add(" ");
        }
        load[4] = "Banana";
        load[1] = "pineapple";
        load[5] = "pear";
        load[7] = "Cat";
        load[6] = "Taco";
        load[9] = "Wae";
        load[0] = "pen";
        load[2] = "Apple";
        load[8] = "De";
        load[3] = "Pen";
        List<string> range = Loader();
        foreach (var item in range)
        Console.WriteLine (item);
        return load;
        }
    }
}

私が試したこと:

main という単語の大文字小文字の変更
別の名前空間を使用する
クラスチェンジ
戻り型の変更

解決策 1

コードを Rextester ページのスケルトンと比較してください。 そこでは Main() メソッドが宣言されている public.

メソッドを Microsoft C# コンパイラで公開する必要はありませんが、Rextester のページでは公開する必要があるようです。

解決策 2

Restfull api is supported (POST only) at https://rextester.com/rundotnet/api. What needs to be supplied are these values (as http data name=val&name2=val2, content type header must not indicate json).
You can get API key by becoming patron at patreon


You can get your questions answered at feedback forum or at patreon if you are a patron.


    LanguageChoice=Language number (see below)
    Program=Code to run
    Input=Input to be supplied to stdin of a process
    CompilerArgs=compiler args as one string (when applicable)
Returned is json string with the following properties:
    Result=Output of a program (in case of Sql Server - html)
    Warnings=Warnings, if any, as one string
    Errors=Errors, if any, as one string
    Stats=Execution stats as one string
    Files=In case of Octave and R - list of png images encoded as base64 strings
Language numbers:
    C# = 1
    VB.NET = 2
    F# = 3
    Java = 4
    Python = 5
    C (gcc) = 6
    C++ (gcc) = 7
    Php = 8
    Pascal = 9
    Objective-C = 10
    Haskell = 11
    Ruby = 12
    Perl = 13
    Lua = 14
    Nasm = 15
    Sql Server = 16
    Javascript = 17
    Lisp = 18
    Prolog = 19
    Go = 20
    Scala = 21
    Scheme = 22
    Node.js = 23
    Python 3 = 24
    Octave = 25
    C (clang) = 26
    C++ (clang) = 27    
    C++ (vc++) = 28
    C (vc) = 29
    D = 30
    R = 31
    Tcl = 32
    MySQL = 33
    PostgreSQL = 34
    Oracle = 35
    Swift = 37
    Bash = 38
    Ada = 39
    Erlang = 40
    Elixir = 41
    Ocaml = 42
    Kotlin = 43
    Brainf*** = 44
    Fortran = 45,
    Rust = 46,
    Clojure = 47

Full javascript example:
<!DOCTYPE html>
<html>
<body>

    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("button").click(function(){

		    var to_compile = {
			    "LanguageChoice": "1",
			    "Program": $("#code").val(),
			    "Input": "",
			    "CompilerArgs" : ""
		    };

		    $.ajax ({
			        url: "https://rextester.com/rundotnet/api",
			        type: "POST",
			        data: to_compile
			    }).done(function(data) {
			        alert(JSON.stringify(data));
			    }).fail(function(data, err) {
			        alert("fail " + JSON.stringify(data) + " " + JSON.stringify(err));
		        });
	    });
    });
    </script>
    </head>

    <textarea id="code">
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text.RegularExpressions;

        namespace Rextester
        {
            public class Program
            {
                public static void Main(string[] args)
                {
                    //Your code goes here
                    Console.WriteLine("Hello, world!");
                }
            }
        }      
    </textarea>
    <button id="run">Run</button>

</body>
</html>

コメント

タイトルとURLをコピーしました