In more advanced programming scenarios, such as using a Windows Runtime component written in C# to provide the application logic for a Windows Store app built for Windows using JavaScript, such differences are apparent in the IDE as well as in the documentation. When your component returns an IDictionary<int, string> to JavaScript, and you look at it in the JavaScript debugger, you'll see the methods of IMap<int, string> because JavaScript uses the Windows Runtime type. Some commonly used collection types that appear differently in the two languages are shown in the following table:
|
Windows Runtime type
|
Corresponding .NET Framework type
|
|
IIterable<T>
|
IEnumerable<T>
|
|
IIterator<T>
|
IEnumerator<T>
|
|
IVector<T>
|
IList<T>
|
|
IVectorView<T>
|
IReadOnlyList<T>
|
|
IMap<K, V>
|
IDictionary<TKey, TValue>
|
|
IMapView<K, V>
|
IReadOnlyDictionary<TKey, TValue>
|
|
IBindableIterable
|
IEnumerable
|
|
IBindableVector
|
IList
|
|
Windows.UI.Xaml.Data.INotifyPropertyChanged
|
System.ComponentModel.INotifyPropertyChanged
|
|
Windows.UI.Xaml.Data.PropertyChangedEventHandler
|
System.ComponentModel.PropertyChangedEventHandler
|
|
Windows.UI.Xaml.Data.PropertyChangedEventArgs
|
System.ComponentModel.PropertyChangedEventArgs
|
In the Windows Runtime, IMap<K, V> and IMapView<K, V> are iterated using IKeyValuePair. When you pass them to managed code, they appear as IDictionary<TKey, TValue> and IReadOnlyDictionary<TKey, TValue>, so naturally you use System.Collections.Generic.KeyValuePair<TKey, TValue> to enumerate them.
The way interfaces appear in managed code affects the way types that implement these interfaces appear. For example, the PropertySet class implements IMap<K, V>, which appears in managed code as IDictionary<TKey, TValue>. PropertySet appears as if it implemented IDictionary<TKey, TValue> instead of IMap<K, V>, so in managed code it appears to have an Add method, which behaves like the Add method on .NET Framework dictionaries. It doesn't appear to have an Insert method.
For more information about using the .NET Framework to create a Windows Runtime component, and a walkthrough that shows how to use such a component with JavaScript, see Creating Windows Runtime Components in C# and Visual Basic in the Windows Dev Center.