Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, we're learning a little bit about C# in a training element for our job and they gave us this code to figure what it does and how everything works. I tried to compile it in this online compiler called Rextester, but it didn't work because of this error. Can someone help guide me and tell me what I should do? I don't know anything about programming, so please forgive me if this whole thing is messed up
This is the code
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;
        }
    }
}


What I have tried:

Changing the case of the word main
using a different namespace
changing the class
changing the return type
Posted
Updated 27-Mar-23 6:58am

Compare your code with the skeleton on the Rextester page. There the Main() method is declared public.

While it is not necessary to make the method public with the Microsoft C# compiler, it seems to be required by the Rextester page.
 
Share this answer
 
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>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900