C#记录泛型使用

public class Car<TFirst,TSecond>
{
    
    
  public TFirst First {
    
     get; }
  public TSecond Second {
    
     get; }
  public Car(TFirst first, TSecond second) => (First, Second) = (first, second);
}
//传入类型和参数即可
 var benci = new Car<string,int>("奔驰",23);
        Debug.Log(benci.First+benci.Second);

猜你喜欢

转载自blog.csdn.net/weixin_42430280/article/details/131412201