Skip to content

Instantly share code, notes, and snippets.

@huanlin
Created March 1, 2022 11:49
Show Gist options
  • Save huanlin/af45703e49cc1cb1e490f5f968afd59a to your computer and use it in GitHub Desktop.
Save huanlin/af45703e49cc1cb1e490f5f968afd59a to your computer and use it in GitHub Desktop.
C# Compiled Record Type
class Student : IEquatable<Student>
{
public int Id { get; init; }
public string Name { get; init; }
public Student(int Id, string Name)
{
this.Id = Id;
this.Name = Name;
}
protected Student(Student orginal)
{
this.Id = original.Id;
this.Name = original.Name;
}
public virtual Student <Clone>$()
=> new Student(this);
public void Deconstruct(...) { ... }
public override string ToString() { ... }
// 省略其他方法,包括改寫的 Equals、GetHashCode 等等。
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment