gpt4 book ai didi

c# - 构建基类构造函数类赋值

转载 作者:行者123 更新时间:2023-11-30 12:46:16 27 4
gpt4 key购买 nike

<分区>

public class Test1
{
public int Q1 { get; set; }
public string Q2 { get; set; }

}

public class Test2 : Test1
{
public Test2(Test1 Value)
{
Q1 = Value.Q1;
Q2 = Value.Q2;
//Does this way of writing is getting very long and difficult

}
}

public class Test2 : Test1
{
public Test2(Test1 Value)
{
base = Value;
//In this way a short and easy ways
}
}



public Test1 ExampleTest()
{
return new Test1();
}

public void Example()
{
Test2 t = new Test2();

t = ExampleTest();
}

我直接赋值给类继承我怎么获取?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com