C#, |
public static Task Main();
public static Task Main();
public static Task Main(string[] args);
public static Task Main(string[] args);
async Task Main(string[] args) {
// -
}
//
int $GeneratedMain(string[] args) {
return Main(args).GetAwaiter().GetResult();
}
void SomeMethod(string[] args)
{
}
SomeMethod(default(string[]));
void SomeMethod(string[] args = default)
{
}
int i = default;
int i = 1;
if (i == default) { } // int 0
if (i is default) { } //
const int? y = default;
if (default == default)
if (default is T) // is default
var i = default
throw default
default as int; // 'as' reference
static Vector3 Add (ref readonly Vector3 v1, ref readonly Vector3 v2)
{
// !
v1 = default(Vector3);
// !
v1.X = 0;
// !
foo(ref v1.X);
//
return new Vector3(v1.X +v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
}
static Vector3 Add (in Vector3 v1, in Vector3 v2)
{
return new Vector3(v1.X +v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
}
interface IA
{
void SomeMethod() { WriteLine(" SomeMethod IA"); }
}
class C : IA { }
IA i = new C();
i.SomeMethod(); // " SomeMethod IA"
// c result f1 f2
var result = list.Select(c => (c.f1, c.f2)).Where(t => t.f2 == 1);
Action y = () => M();
var t = (x: x, y);
t.y(); // extension method y(),
Tuple element name 'y' is inferred. Please use language version 7.1 or greater to access an element by its inferred name.
class Program
{
static void Main(string[] args)
{
string x = "demo";
Action y = () => M();
var t = (x: x, y);
t.y(); // extension method y(),
}
private static void M()
{
Console.WriteLine("M");
}
}
public static class MyExtensions
{
public static void y(this (string s, Action a) tu)
{
Console.WriteLine("extension method");
}
}