Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to add new namespace in c# windows form application?? please explain it in detail ..
Posted
Comments
Pravuprasad 18-Sep-14 7:01am    
use using keyword for adding namespace if reference is already added else right click on solution->add reference-> select .dll file and then use using namespacename;

If you search in google you can find many examples regarding NameSpaces.
Among them Try
Link1
Link2
thanks
 
Share this answer
 
v3
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.
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

Then of course it depends which namespace you want to add.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900