Created
March 1, 2022 11:49
-
-
Save huanlin/af45703e49cc1cb1e490f5f968afd59a to your computer and use it in GitHub Desktop.
C# Compiled Record Type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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