概要
中古ノート買ってみた。
wsl1のubuntu18.04にmono入れてみた。
Mono付属のcsharpコマンドを使ってみた。
Monoのcsharpコマンドを使ってみた。
csharpは、C#のインタラクティブシェルです。
これはMono C#インタプリタで、C#のコードをその場で実行したりテストしたりするのに便利です。
コード補完も付いてます。
# csharp
Mono C# Shell, type "help;" for help
Enter statements below.
csharp> help
"Static methods:
Describe (object); - Describes the object's type
LoadPackage (package); - Loads the given Package (like -pkg:FILE)
LoadAssembly (assembly); - Loads the given assembly (like -r:ASSEMBLY)
ShowVars (); - Shows defined local variables.
ShowUsing (); - Show active using declarations.
Prompt - The prompt used by the C# shell
ContinuationPrompt - The prompt for partial input
Time (() => { }); - Times the specified code
print (obj); - Shorthand for Console.WriteLine
quit; - You'll never believe it - this quits the repl!
help; - This help text
TabAtStartCompletes - Whether tab will complete even on empty lines
"
csharp> a=12
(1,2): error CS0103: The name `a' does not exist in the current context
csharp> int a=12;
csharp> print(a);
12
csharp> print(a)
12
csharp> print a
(1,2): error CS0118: `Mono.CSharp.InteractiveBase.print(object)' is a `method' but a `type' was expected
csharp> time
(1,2): error CS0103: The name `time' does not exist in the current context
csharp> ShowVars()
int a = 12
csharp> ShowUsing()
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
csharp> class Test {
> public Main(){
> Console.WriteLine("ok");
> }
> }
(2,8): error CS1520: Class, struct, or interface method must have a return type
csharp> class Test {
> public void Main(){
> Console.WriteLine("ok");
> }
> }
csharp> var t = new Test{};
csharp> t.Main();
ok
csharp>
以上。