假设我有一个c#类A,它继承自B类,后者继承自C类。
Class A : Class B
{}
Class B : Class C
{
override OnIntialise()
{
do something else...
}
}
Class C
{
virtual Initialise()
{
OnIntialise();
}
virtual OnInitialise()
{
do something...
}
}
现在当我调用a.Initialise()时,程序将调用Class C中定义的方法Initialise()。在Initialise()中,是否会调用在C类或B类中定义的OnIntialise()方法?
答案 0 :(得分:0)
Sub UniqueNumber()
Dim vDB, vR(), a
Dim i As Integer, j As Integer, n As Long, z As Integer
Dim k As Integer, p As Integer
Dim dic As Object
Dim s As String
Set dic = CreateObject("Scripting.Dictionary")
vDB = Range("a2", Range("a" & Rows.Count).End(3))
z = UBound(vDB, 1)
ReDim Preserve vR(1 To 3)
For i = 1 To z: For j = 1 To z: For k = 1 To z
If i <> j And i <> k And j <> k Then
vR(1) = vDB(i, 1)
vR(2) = vDB(j, 1)
vR(3) = vDB(k, 1)
s = Join(vR, "")
If dic.Exists(s) Then
Else
n = n + 1
dic.Add s, s
End If
End If
Next k: Next j: Next i
a = dic.Keys
Range("d2").CurrentRegion.Offset(1).Clear
Range("d2").Resize(n) = WorksheetFunction.Transpose(a)
End Sub
的类Initialise
方法,因为它在子类中被重写,即类B
。如果在类B
中重写了此方法,那么类A
中的方法将被调用。