Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from Ourpalm:master #99

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion TestCases/InheritanceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,44 @@ public static void InheritanceTest23()
if (cls5 is InterfaceTest2)
throw new Exception();
}
public static void InheritanceTest24()
{
ListSub list = new ListSub();
float res = list.Update(0, 1);
if (res < 10)
throw new Exception();
}
class ListSub : AbstractBase
{
List<AbstractBase> children = new List<AbstractBase>();
public ListSub()
{
for (int i = 0; i < 10; i++)
children.Add(new ListSub2());
}

public override float Update(float a, float b)
{
float baseVal = a;
foreach (var i in children)
{
baseVal += i.Update(baseVal, b);
}
return baseVal;
}
}

class ListSub2 : AbstractBase
{
public override float Update(float a, float b)
{
return a + b;
}
}
abstract class AbstractBase
{
public abstract float Update(float a, float b);
}

class TestExplicitInterface : IDisposable
{
Expand Down Expand Up @@ -552,7 +590,7 @@ void InheritanceTest06_Sub<T>() where T:MyClass
T obj = Activator.CreateInstance(typeof(T)) as T; //这样写错误
//MyClass obj = Activator.CreateInstance(typeof(T)) as MyClass; //这样写正确
obj.Reg();
}
}

interface IMy
{
Expand Down
Loading