Automation.Compare 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
比较指定参数以确定它们是否引用相同的用户界面 (UI) 元素。
重载
| Compare(Int32[], Int32[]) |
比较包含运行时标识符的两个整数数组 (ID) ,以确定其内容是否相同。 |
| Compare(AutomationElement, AutomationElement) |
比较两个UI 自动化元素,如果两个元素都引用相同的 UI 元素,则 |
Compare(Int32[], Int32[])
比较包含运行时标识符的两个整数数组 (ID) ,以确定其内容是否相同。
public:
static bool Compare(cli::array <int> ^ runtimeId1, cli::array <int> ^ runtimeId2);
public static bool Compare (int[] runtimeId1, int[] runtimeId2);
static member Compare : int[] * int[] -> bool
Public Shared Function Compare (runtimeId1 As Integer(), runtimeId2 As Integer()) As Boolean
参数
- runtimeId1
- Int32[]
要比较的第一个运行时 ID。
- runtimeId2
- Int32[]
要比较的第二个运行时 ID。
返回
true 如果比较的运行时 ID 引用同一用户界面 (UI) 元素;否则 false。
示例
以下示例函数确定运行时 ID 是否位于运行时 ID 列表中。
private int RuntimeIdListed(int[] runtimeId, ArrayList runtimeIds)
{
for (int x = 0; x < runtimeIds.Count; x++)
{
int[] listedId = (int[])runtimeIds[x];
if (Automation.Compare(listedId, runtimeId))
{
return x;
}
}
return -1;
}
Private Function RuntimeIdListed(ByVal runtimeId() As Integer, ByVal runtimeIds As ArrayList) As Integer
Dim x As Integer
For x = 0 To runtimeIds.Count - 1
Dim listedId As Integer() = CType(runtimeIds(x), Integer())
If Automation.Compare(listedId, runtimeId) Then
Return x
End If
Next x
Return - 1
End Function 'RuntimeIdListed
注解
如果任一参数是Visual Basic) 中的 null 引用 (Nothing,Compare则ArgumentNullException引发异常。
另请参阅
适用于
Compare(AutomationElement, AutomationElement)
比较两个UI 自动化元素,如果两个元素都引用相同的 UI 元素,则true返回。
public:
static bool Compare(System::Windows::Automation::AutomationElement ^ el1, System::Windows::Automation::AutomationElement ^ el2);
public static bool Compare (System.Windows.Automation.AutomationElement el1, System.Windows.Automation.AutomationElement el2);
static member Compare : System.Windows.Automation.AutomationElement * System.Windows.Automation.AutomationElement -> bool
Public Shared Function Compare (el1 As AutomationElement, el2 As AutomationElement) As Boolean
参数
要比较的第一个UI 自动化元素。
要比较的第二个UI 自动化元素。
返回
true 如果 UI 元素的运行时标识符相同,则为否则 false。
注解
如果任一参数是Visual Basic) 中的 null 引用 (Nothing,Compare则ArgumentNullException引发异常。
此方法等效于对象的相等运算符 AutomationElement 。