Tea-与-C#-的不同点

优质
小牛编辑
131浏览
2023-12-01
C# 代码等效的 Tea 代码不同的原因
using 名字空间;import 包;叫法不同
namespace A{}module A; // 一个文件只能用一次
extern alias s;
s::System.IO.File;
import module as s;
s.File
internal(无)
A a = new A(1) {p = 4, t = 2};A a = new A(1)..p = 4..t = 2;
foreach(int item in arr){

}

for(int item in arr){

}

switch { case 1: case 2: {break;} default: {break;} }switch { case 1, 2: {} case else: {} }
using(A a = new A()){}with(A a = new A()) {}
fixed(int* p = &r){ }with(int* p = &r){ }
var a = fn();
dynamic b = 4;
var a = fn();
object b = 4;
int? a = null;
int? b = a ?? 4;
(无)
int[] a = {1, 2, 3};
var list = new List{1, 2, 3};
int[] a = [1, 2, 3];
var list = [1, 2, 3] as List;
var fn = (e) => { return e + e };var fn = (e) -> { return e + e };
class QAttribute : Attribute {}

class A {
[q]
int aa;
}

lass QAnnotation : Annotation {}

class A {
@q
int aa;
}

static class AExtensions {
void fn(this A a);
}
extend A {
void fn();
}
class A{
public static A operator +(A a, A b) {}
public static explicit operator B(A a) {}
}
class A{
A this +(A b) {}
as B() {}
}