In this Article , I will explain create and call namespace using C#.net in the Application.
First of all , we should know Namespace and it usage.
Namespace:
Namespace is a Collection of classes.
Implementing Namespaces in your own code is a good habit because it is likely to save you from problems later when you want to reuse some of your code.
user can create more than 1 class files and user can create enum within class file.
Use of Namespace:
Namespaces allow you to create a system to organize your code.
Syntax of Namespace:
namespace <namespace_name>
class <class_name>
Method <method_name>
For Eg:
using System;
namespace Test_namespace
{
class cls_namespace
{
public static void messageDisplay()
{
System.Windows.Forms.MessageBox.Show("Create Namespace");
}
}
}
In this Example, we create a namespace that is called Test_namespace,we add class in the namespace that is called cls_namespace and we create method in the Class that is called messageDisplay.
How to call the Namespace in the C#.net?
First ,we create an Application in the VS 2008.
we just add a Code file in the Project and name is called "Test_namespace".
Copy code and paste into Code File.
using System;
namespace Test_namespace
{
class cls_namespace
{
public static void messageDisplay()
{
System.Windows.Forms.MessageBox.Show("Create Namespace");
}
}
}
How to call a Namespace in the C#.net Project?
just use "Using" Keyword for declare namespace in the Parent
Open Project Code view
call a Namespace in the Code View.
using Test_namespace;
call a Method in the Load Event.
Copy code and paste into Code view.
cls_namespace.messageDisplay();
Run the Application . User can see the MessageBox before form loading
First of all , we should know Namespace and it usage.
Namespace:
Namespace is a Collection of classes.
Implementing Namespaces in your own code is a good habit because it is likely to save you from problems later when you want to reuse some of your code.
user can create more than 1 class files and user can create enum within class file.
Use of Namespace:
Namespaces allow you to create a system to organize your code.
Syntax of Namespace:
namespace <namespace_name>
class <class_name>
Method <method_name>
For Eg:
using System;
namespace Test_namespace
{
class cls_namespace
{
public static void messageDisplay()
{
System.Windows.Forms.MessageBox.Show("Create Namespace");
}
}
}
In this Example, we create a namespace that is called Test_namespace,we add class in the namespace that is called cls_namespace and we create method in the Class that is called messageDisplay.
How to call the Namespace in the C#.net?
First ,we create an Application in the VS 2008.
we just add a Code file in the Project and name is called "Test_namespace".
Copy code and paste into Code File.
using System;
namespace Test_namespace
{
class cls_namespace
{
public static void messageDisplay()
{
System.Windows.Forms.MessageBox.Show("Create Namespace");
}
}
}
How to call a Namespace in the C#.net Project?
just use "Using" Keyword for declare namespace in the Parent
Open Project Code view
call a Namespace in the Code View.
using Test_namespace;
call a Method in the Load Event.
Copy code and paste into Code view.
cls_namespace.messageDisplay();
Run the Application . User can see the MessageBox before form loading
No comments:
Post a Comment