IGrouping<TKey, TElement>::Key Property
Gets the key of the IGrouping<TKey, TElement>.
Assembly: System.Core (in System.Core.dll)
The key of an IGrouping<TKey, TElement> represents the attribute that is common to each value in the IGrouping<TKey, TElement>.
The following example demonstrates how to use the Key property to label each IGrouping<TKey, TElement> object in a sequence of IGrouping<TKey, TElement> objects. The GroupBy<TSource, TKey>(IEnumerable<TSource>^, Func<TSource, TKey>^) method is used to obtain a sequence of IGrouping<TKey, TElement> objects. The foreach in Visual C# or For Each in Visual Basic loop then iterates through each IGrouping<TKey, TElement> object, outputting its key and the number of values it contains.
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1