使用和Java导入C#的区别 [英] Difference between c# using and Java import

查看:135
本文介绍了使用和Java导入C#的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,在java中,我们使用*(星号),以导入包中的所有内容如

 进口的java.lang。*;

那么我们为什么不使用相同的*(星号)在C#中导入所有的内容是有没有像在Java中导入所有内容的任何方法。
之间有什么

的区别

 进口java.awt中的*。

 使用System.Windows.Forms的;


解决方案

什么是Java的导入做什么.NET被称为参考 - 添加的引用的在.NET程序集,您可以使用该程序集中定义的(公共)类型。

使用指令 C#的 是简单地访问这些类型而无需键入出整个空间的一种方式。

您可以的使用指令来提供命名空间的别名。

I know that in java that we use *(asterisk) to import all the contents in a package like

import java.lang.*;

Then why don't we use same *(asterisk) in C# to import all the contents is there any method like in java to import all the contents. What is the difference between

import java.awt.*;

and

using System.windows.forms;

What the Java import does what .NET is called a reference - adding a reference to an assembly in .NET allows you to use the (public) types defined in that assembly.

The C# using directive is simply a way to access these types without typing out the whole namespace.

You can also use the directive to provide namespace aliases.

这篇关于使用和Java导入C#的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆