|
Dieser Artikel wurde maschinell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen. Weitere Informationen
|
Übersetzung
Original
|
List<T>.Contains-Methode
Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { List<Box> boxes = new List<Box>(); boxes.Add(new Box(8, 8, 4)); boxes.Add(new Box(8, 4, 8)); boxes.Add(new Box(8, 6, 4)); if (boxes.Contains(new Box(8, 6, 4))) { Console.WriteLine("An equal box is already in the collection."); } else { Console.WriteLine("Box can be added."); } //Outputs "An equal box is already in the collection." } } public class Box : IEquatable<Box> { public Box(int h, int l, int w) { this.Height = h; this.Length = l; this.Width = w; } public int Height { get; set; } public int Length { get; set; } public int Width { get; set; } public bool Equals(Box other) { if (this.Height == other.Height && this.Length == other.Length && this.Width == other.Width) { return true; } else { return false; } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core-Rolle wird nicht unterstützt), Windows Server 2008 R2 (Server Core-Rolle wird mit SP1 oder höher unterstützt; Itanium wird nicht unterstützt)
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.