如何在c#windows窗体应用程序中添加新的命名空间?请详细解释.. [英] how to add new namespace in c# windows form application? please explain it in detail ..

查看:462
本文介绍了如何在c#windows窗体应用程序中添加新的命名空间?请详细解释..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在c#windows窗体应用程序中添加新命名空间?请详细解释..

how to add new namespace in c# windows form application?? please explain it in detail ..

推荐答案

如果你在谷歌搜索你可以找到很多关于NameSpaces的例子。

其中试试

Link1

Link2

谢谢
If you search in google you can find many examples regarding NameSpaces.
Among them Try
Link1
Link2
thanks


我假设您的意思是如何添加装配参考。



如何:添加或删除参考文献使用参考管理器 [ ^ ]



如果您的问题确实是添加命名空间,您只需在源代码文件的顶部添加与此类似的行。

I assume you mean how to add an assembly reference.

How to: Add or Remove References By Using the Reference Manager[^]

If your question really is to add a namespace you just add lines similar to this at the top of the source code file.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;



当然,它取决于您要添加的名称空间。


Then of course it depends which namespace you want to add.


从技术上讲,C#中的命名空间是一个语义结构,用于控制类,方法等的范围。您可能会说命名空间的范围是其中的上下文。名称的定义是有效的。



C#中的命名空间有两种广义的定义:



1. .NET Framework本身使用命名空间来组织它的设施/库,比如你激活的System,System.Windows.Forms等...使它们的内容可供WinForm文件中的类使用...使用Win表头中的'using关键字调用它们。



2.用于组织代码并防止语义混淆的用户定义的命名空间。



请查看文档:[ ^ ],[ ^ ]。



您可以根据需要定义自己的命名空间。您可以使用嵌套的命名空间,并且可以创建引用命名空间的别名('using运算符的变体):对于命名空间别名的使用,请参阅:[ ^ ]。



使用Visual Studio时为您创建一个新项目(C#WinForms),请注意项目的名称空间会自动创建并用于项目的各个组件(主窗体,Designer.cs文件,程序文件)。这些声明(在任何'using语句之后)使用'namespace关键字后跟命名空间的名称,后跟括号{},括起整个代码在这些命名空间中。
Technically, a Namespace in C# is a semantic construct used to control the "scope" of Classes, Methods, etc. You might say that the scope of a Namespace is the context in which its "definitions" of names are valid.

A Namespace in C# is defined in two broad ways:

1. the .NET Framework itself uses Namespaces to organize its facilities/libraries, like System, System.Windows.Forms, etc. that you activate ... make their contents available to available to classes in a WinForm File ... by invoking them using the 'using keyword in a Win Form header.

2. user-defined Namespaces that you use to organize your code and prevent semantic confusion.

Please review the documentation: [^], [^].

You can define as many Namespaces of your own as you wish. You can use nested Namespaces, and you can create aliases that refer to Namespaces (a variant of the 'using operator): for the use of Namespace alias see: [^].

When you use Visual Studio to create a new Project for you (C# WinForms), note that Namespaces for the project are automatically created and used in the various components of the Project (Main Form, Designer.cs file, Program file). These are declared (after any 'using statements) with the 'namespace keyword followed by the name of the Namespace, followed by curly braces {} that bracket the entire code in those Namespaces.


这篇关于如何在c#windows窗体应用程序中添加新的命名空间?请详细解释..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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