DataTableMappingCollection.Contains Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a value indicating whether a particular DataTableMapping object exists in the collection.
Overloads
Contains(Object) |
Gets a value indicating whether the given DataTableMapping object exists in the collection. |
Contains(String) |
Gets a value indicating whether a DataTableMapping object with the specified source table name exists in the collection. |
Contains(Object)
Gets a value indicating whether the given DataTableMapping object exists in the collection.
public:
virtual bool Contains(System::Object ^ value);
public bool Contains (object? value);
public bool Contains (object value);
abstract member Contains : obj -> bool
override this.Contains : obj -> bool
Public Function Contains (value As Object) As Boolean
Parameters
- value
- Object
An Object that is the DataTableMapping.
Returns
true
if this collection contains the specified DataTableMapping; otherwise false
.
Implements
Examples
The following example searches for a DataTableMapping within the collection. If the mapping exists in the collection, it is removed. If the mapping does not exist within the collection, it is added to the collection and its index is displayed. The example assumes that a DataTableMappingCollection collection and a DataTableMapping object have been created.
public void ChangedMyMind()
{
// ...
// create mappings and mapping
// ...
if (mappings.Contains((Object) mapping))
{
mappings.Remove((Object) mapping);
}
else
{
mappings.Add((Object) mapping);
Console.WriteLine("Index of new mapping: "
+ mappings.IndexOf((Object) mapping));
}
}
Public Sub ChangedMyMind()
' ...
' create mappings and mapping
' ...
If mappings.Contains(CType(mapping, Object)) Then
mappings.Remove(CType(mapping, Object))
Else
mappings.Add(CType(mapping, Object))
Console.WriteLine("Index of new mapping: " _
& mappings.IndexOf(CType(mapping, Object)).ToString())
End If
End Sub
Applies to
Contains(String)
Gets a value indicating whether a DataTableMapping object with the specified source table name exists in the collection.
public:
virtual bool Contains(System::String ^ value);
public bool Contains (string? value);
public bool Contains (string value);
abstract member Contains : string -> bool
override this.Contains : string -> bool
Public Function Contains (value As String) As Boolean
Parameters
- value
- String
The case-sensitive source table name containing the DataTableMapping object.
Returns
true
if the collection contains a DataTableMapping object with this source table name; otherwise false
.
Implements
Examples
The following example searches for a DataTableMapping object with the given source table name within a DataTableMappingCollection collection. If the DataTableMapping exists, the example displays the name and the index of the mapping. If the mapping does not exist, the example displays an error. This example assumes that a DataTableMappingCollection collection has been created.
public void FindDataTableMapping()
{
// ...
// create mappings
// ...
if (!mappings.Contains("Categories"))
Console.WriteLine("Error: no such table in collection");
else
Console.WriteLine
("Name: " + mappings["Categories"].ToString() + "\n"
+ "Index: " + mappings.IndexOf("Categories").ToString());
}
Public Sub FindDataTableMapping()
' ...
' create mappings
' ...
If Not mappings.Contains("Categories") Then
Console.WriteLine("Error: no such table in collection")
Else
Console.WriteLine("Name: " & mappings("Categories").ToString() _
& ControlChars.Cr + "Index: " _
& mappings.IndexOf("Categories").ToString())
End If
End Sub