本文列出了 .NET 在 Windows 執行階段 (WinRT) 類型與使用受控程式碼撰寫的通用 Windows 平台 (UWP) 應用程式中的 .NET 類型之間進行的對應。 在這些應用程式中,Visual Studio IntelliSense 會顯示 .NET 類型,而不是 WinRT 類型。 例如,如果 WinRT 方法採用 IVector<string> 類型的參數,則 IntelliSense 會顯示 IList<string> 類型的參數。 同樣地,在使用受控程式碼撰寫的 Windows 執行階段元件中,您可以在成員簽章中使用 .NET 類型。 當 Windows 執行階段元資料匯出工具 (Winmdexp.exe) 產生 Windows 執行階段元件時,.NET 類型將轉換為相應的 WinRT 類型。
WinRT 和 .NET 中具有相同命名空間名稱和類型名稱的大多數類型都是結構 (或與結構關聯的類型,例如列舉)。 在 WinRT 中,結構只有欄位成員,而且需要協助程式類型,而這是 .NET 會隱藏的項目。 這些結構的 .NET 版本具有提供隱藏協助程式類型功能的屬性和方法。
對應到具有相同名稱和命名空間的 .NET 類型的 WinRT 類型
在 .NET 組件 System.ObjectModel.dll 中
| Namespace |
類型 |
| Windows.UI.Xaml.Input |
ICommand |
在 .NET 組件 System.Runtime.WindowsRuntime.dll 中
| Namespace |
類型 |
| Windows.Foundation |
Point |
| Windows.Foundation |
[週框] |
| Windows.Foundation |
大小 |
| Windows.UI |
Color |
在 .NET 組件 System.Runtime.WindowsRuntime.UI.Xaml.dll 中
| Namespace |
類型 |
| Windows.UI.Xaml |
CornerRadius |
| Windows.UI.Xaml |
期間 |
| Windows.UI.Xaml |
DurationType |
| Windows.UI.Xaml |
GridLength |
| Windows.UI.Xaml |
GridUnitType |
| Windows.UI.Xaml |
Thickness |
| Windows.UI.Xaml.Controls.Primitives |
GeneratorPosition |
| Windows.UI.Xaml.Media |
矩陣 |
| Windows.UI.Xaml.Media.Animation |
KeyTime |
| Windows.UI.Xaml.Media.Animation |
RepeatBehavior |
| Windows.UI.Xaml.Media.Animation |
RepeatBehaviorType |
| Windows.UI.Xaml.Media.Media3D |
Matrix3D |
對應到具有不同名稱和/或命名空間的 .NET 類型的 WinRT 類型
在 .NET 組件 System.ObjectModel.dll 中
| WinRT 類型/命名空間 |
.NET 類型/命名空間 |
| INotifyCollectionChanged (Windows.UI.Xaml.Interop) |
INotifyCollectionChanged (System.Collections.Specialized) |
| NotifyCollectionChangedEventHandler (Windows.UI.Xaml.Interop) |
NotifyCollectionChangedEventHandler (System.Collections.Specialized) |
| NotifyCollectionChangedEventArgs (Windows.UI.Xaml.Interop) |
NotifyCollectionChangedEventArgs (System.Collections.Specialized) |
| NotifyCollectionChangedAction (Windows.UI.Xaml.Interop) |
NotifyCollectionChangedAction (System.Collections.Specialized) |
| INotifyPropertyChanged (Windows.UI.Xaml.Data) |
INotifyPropertyChanged (System.ComponentModel) |
| PropertyChangedEventHandler (Windows.UI.Xaml.Data) |
PropertyChangedEventHandler (System.ComponentModel) |
| PropertyChangedEventArgs (Windows.UI.Xaml.Data) |
PropertyChangedEventArgs (System.ComponentModel) |
在 .NET 組件 System.Runtime.dll 中
| WinRT 類型/命名空間 |
.NET 類型/命名空間 |
| AttributeUsageAttribute (Windows.Foundation.Metadata) |
AttributeUsageAttribute (System) |
| AttributeTargets (Windows.Foundation.Metadata) |
AttributeTargets (System) |
| DateTime (Windows.Foundation) |
DateTimeOffset (System) |
| EventHandler<T> (Windows.Foundation) |
EventHandler<T> (System) |
| HResult (Windows.Foundation) |
Exception (System) |
| IReference<T> (Windows.Foundation) |
Nullable<T> (System) |
| TimeSpan (Windows.Foundation) |
TimeSpan (System) |
| Uri (Windows.Foundation) |
Uri (System) |
| IClosable (Windows.Foundation) |
IDisposable (System) |
| IIterable<T> (Windows.Foundation.Collections) |
IEnumerable<T> (System.Collections.Generic) |
| IVector<T> (Windows.Foundation.Collections) |
IList<T> (System.Collections.Generic) |
| IVectorView<T> (Windows.Foundation.Collections) |
IReadOnlyList<T> (System.Collections.Generic) |
| IMap<K,V> (Windows.Foundation.Collections) |
IDictionary<TKey,TValue> (System.Collections.Generic) |
| IMapView<K,V> (Windows.Foundation.Collections) |
IReadOnlyDictionary<TKey,TValue> (System.Collections.Generic) |
| IKeyValuePair<K,V> (Windows.Foundation.Collections) |
KeyValuePair<TKey,TValue> (System.Collections.Generic) |
| IBindableIterable (Windows.UI.Xaml.Interop) |
IEnumerable (System.Collections) |
| IBindableVector (Windows.UI.Xaml.Interop) |
IList (System.Collections) |
| TypeName (Windows.UI.Xaml.Interop) |
Type (System) |
在 .NET 組件 System.Runtime.InteropServices.WindowsRuntime.dll 中
| WinRT 類型/命名空間 |
.NET 類型/命名空間 |
| EventRegistrationToken (Windows.Foundation) |
EventRegistrationToken (System.Runtime.InteropServices.WindowsRuntime) |