OneOrMany<T> Structure

Visual Studio 2015
 

A collection of T that is optimized for minimal space in the case of a single element.

Namespace:   Microsoft.VisualStudio.Utilities
Assembly:  Microsoft.VisualStudio.Utilities (in Microsoft.VisualStudio.Utilities.dll)

[DebuggerDisplayAttribute("Count = {Count}")]
public struct OneOrMany<T>
where T : class

Type Parameters

T

The elemental type, which must be a reference type. Note: null may not be used as a value in the collection.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of elements in the collection.

System_CAPS_pubpropertyItem[Int32]

Gets the element at the specified index in the collection.

NameDescription
System_CAPS_pubmethodAdd(T)

Adds a new value to the collection.

System_CAPS_pubmethodEquals(Object)

(Inherited from ValueType.)

System_CAPS_pubmethodGetEnumerator()

Gets the enumerator for the collection.

System_CAPS_pubmethodGetHashCode()

(Inherited from ValueType.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodRemoveAt(Int32)

Removes the item at the specified index from the collection.

System_CAPS_pubmethodToString()

(Inherited from ValueType.)

While this type has a GetEnumerator method, it does not implement IEnumerable{T}. This is to eliminate any unintentional boxing that will happen if a value type is passed to or returned from a method via its interface. The collection may still be enumerated in foreach statements (since the compiler uses pattern matching for that), but not elsewhere (for example, LINQ expressions).

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: