1using System; 2 3namespace Demo.Ns 4{ 5 /// sample class 6 public class ClassSample : Base 7 { 8 /* sample multiline comment */ 9#region region sample 10 fieldSample : int; 11#endregion 12 13 public virtual someMethod(str : string) : list[double] 14 { 15 def x = "simple string"; 16 def x = $"simple $splice string $(spliceMethod() + 1)"; 17 def x = <# 18 recursive <# string #> sample 19 #>; 20 def x = $<# 21 recursive $splice <# string #> sample 22 ..$(lst; "; "; x => $"x * 2 = $(x * 2)") str 23 #>; 24 def x = @"somestring \"; 25 26 def localFunc(arg) 27 { 28 arg + 1; 29 } 30 31 match (localFunc(2)) 32 { 33 | 3 => "ok"; 34 | _ => "fail"; 35 } 36 37 using (x = SomeObject()) 38 { 39 foreach (item in someCollection) 40 { 41 def i = try 42 { 43 int.Parse(item) 44 } 45 catch 46 { 47 | _ is FormatException => 0; 48 } 49 when (i > 0xff) 50 unless (i < 555L) 51 WriteLine(i); 52 53 } 54 } 55 protected override overrideSample() : void 56 {} 57 58 private privateSample() : void 59 {} 60 61 public abstract abstractSample() : void 62 {} 63 } 64 65 } 66 67 module ModuleSample 68 { 69 } 70 71 variant RgbColor { 72 | Red 73 | Yellow 74 | Green 75 | Different { 76 red : float; 77 green : float; 78 blue : float; 79 } 80 } 81 82 macro sampleMacro(expr) 83 syntax ("write", expr) 84 { 85 <[ WriteLine($(expr : dyn)) ]> 86 } 87} 88