在我的C#应用程序我平时看到的两个主要的命名空间System和Windows,例如:
系统:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
Run Code Online (Sandbox Code Playgroud)
视窗:
using Windows.Foundation;
using Windows.Media.Capture;
using Windows.Media.MediaProperties;
Run Code Online (Sandbox Code Playgroud)
这两个命名空间有什么区别?在.NET类属于哪个命名空间方面,它们之间是否存在逻辑划分?
Windows命名空间(强调我的):
该
Windows命名空间(Windows.Foundation,Windows.UI,Windows.UI.Xaml,Windows.UI.Xaml.Controls.Primitives,Windows.UI.Xaml.Media,Windows.UI.Xaml.Media.Animation,和Windows.UI.Xaml.Media.Media3D)包含类型管理应用程序的用户界面.... Windows命名空间中的类型[包含在.NET for Windows 8.x商店应用程序中].请注意,.NET for Windows 8.x商店应用程序不包括每种类型的所有成员.有关各个类型的信息,请参阅链接的主题.类型的文档指示.NET for Windows 8.x Store应用程序中包含哪些成员.
该
System命名空间中包含定义常用值和引用数据类型,事件和事件处理程序,接口,属性和处理异常的基础类和基类.
要回答您的问题,Windows命名空间中的类型仅适用于Windows ; 那些与System平台无关的(正如@DStanley在评论中指出的那样).
请注意,C#可以在不同于Windows的平台上运行 - 例如,使用Mono(适用于Linux)或Xamarin(适用于iOS或Android等).