DBProviderInfos.Contains(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回一个布尔值,指示集合中的项目是否可以通过索引访问而不抛出异常。
public:
bool Contains(System::Object ^ index);
public bool Contains(object index);
member this.Contains : obj -> bool
Public Function Contains (index As Object) As Boolean
参数
- index
- Object
包含该对象名称、描述或索引的对象。
返回
一个布尔值,指示集合是否可以通过名称、描述或作为索引参数传递的索引访问。 值为真表示可以使用语法DBProviderInfos[index]访问该集合。 值为false表示索引无法用于从集合中检索项目 DBProviderInfos 。
示例
以下代码示例使用 Contains 方法打印集合中第一个项目的名称。 该方法返回一个 Boolean。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
namespace DBProvInfos_GetEnum
{
class Program
{
static void Main(string[] args)
{
Application app = new Application();
DBProviderInfos dbprovInfos = app.DBProviderInfos;
// Search for the MediaCatalogDB provider in the collection
if (dbprovInfos.Contains(0))
Console.WriteLine("The collection contains {0} provider", dbprovInfos[0].Name);
else
Console.WriteLine("The collection does not contain {0} provider", dbprovInfos[0].Name);
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Namespace DBProvInfos_GetEnum
Class Program
Shared Sub Main(ByVal args() As String)
Dim app As Application = New Application()
Dim dbprovInfos As DBProviderInfos = app.DBProviderInfos
' Search for the MediaCatalogDB provider in the collection
If dbprovInfos.Contains(0) Then
Console.WriteLine("The collection contains {0} provider", dbprovInfos(0).Name)
Else
Console.WriteLine("The collection does not contain {0} provider", dbprovInfos(0).Name)
End If
End Sub
End Class
End Namespace
示例输出:
该集合包含 MediaCatalogDB OLE 数据库提供者