What is namespace in c#
A namespace is a collection of classes and Using is
keyword to import namespace(Using is just like #include in C-Language), their
are various inbuilt namespaces available in C#.net.
1. Data --is a namespace for database connectivity.
2. A System(Root namespace) is the namespace that consists of several classes
for a basic operation like Console.
3. A namespace is consist of several of the class
4. MVC is a namespace which consists of several class for defining the
webpage by MVC.
List of most common namespaces used in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Web.Script.Serialization;
using System.Diagnostics;
using System.Net;
using System.IO;
using System.Text;
using Microsoft.Ajax.Utilities;
using System.Configuration;
System:
The system is a root namespace in c#, whenever we write any code we need to use using System; namespace to get all the basic programming features.
How to use User Defined Namespace in c#
In c# language we can define our own namespace by using the keyword namespace Let's understand the concept of a user-defined namespace.
Suppose, there is a class bank and is available in the group1 namespace, see the example.
using System; // root namespace
namespace group1 // user-defined namespace
{
{
public class bank
{
// function and variables
}
}
Now, If you want to access the bank class, you need to have included the namespace where you are going to accessing it (in another class/project).
using System; // root namespaceusing group1 // accessing the user-defined namespace
namespace group2 // user-defined namespace
{
public class employee { public static void Main() {
bank obj = new bank ();// Displays 'My Class'
} }
}
What is class and the architecture of class in c#
Class is a keyword. Class allow creating a user-defined data type
within a class, we can have multiples of variables Every type of variable plays a
significant
role by developing the application
For Example:
>When we declare the class in c#, a variable can have 5 kinds of scope.
- Private
- Public
- protected
- Internal
- Protected internal
If we declare a class in c# by default scope of the class is Internal.
If we declare the variable within the class by default scope is private.
Whenever write a class in c# by default it is child class or derives
class inherited from an object class(base class)
What is namespace in c#
A namespace is a collection of classes and Using is
keyword to import namespace(Using is just like #include in C-Language), their
are various inbuilt namespaces available in C#.net.
1. Data --is a namespace for database connectivity.
2. A System(Root namespace) is the namespace that consists of several classes
for a basic operation like Console.
3. A namespace is consist of several of the class
4. MVC is a namespace which consists of several class for defining the
webpage by MVC.
List of most common namespaces used in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Web.Script.Serialization;
using System.Diagnostics;
using System.Net;
using System.IO;
using System.Text;
using Microsoft.Ajax.Utilities;
using System.Configuration;
System:
The system is a root namespace in c#, whenever we write any code we need to use using System; namespace to get all the basic programming features.
How to use User Defined Namespace in c#
In c# language we can define our own namespace by using the keyword namespace Let's understand the concept of a user-defined namespace.
Suppose, there is a class bank and is available in the group1 namespace, see the example.
using System; // root namespace
namespace group1 // user-defined namespace
{
{
public class bank
{
// function and variables
}
}
Now, If you want to access the bank class, you need to have included the namespace where you are going to accessing it (in another class/project).
using System; // root namespace
using group1 // accessing the user-defined namespace
namespace group2 // user-defined namespace
{
public class employee
{
public class employee
{
public static void Main()
{bank obj = new bank ();// Displays 'My Class'
}
}
}
}
What is class and the architecture of class in c#
Class is a keyword. Class allow creating a user-defined data type
within a class, we can have multiples of variables Every type of variable plays a
significant
role by developing the application
For Example:
For Example:
>When we declare the class in c#, a variable can have 5 kinds of scope.
- Private
- Public
- protected
- Internal
- Protected internal
If we declare a class in c# by default scope of the class is Internal.
If we declare the variable within the class by default scope is private.
Whenever write a class in c# by default it is child class or derives
class inherited from an object class(base class)
using System;
class Employee //(Employee is the custom type that is
define by me)
{
int a;
string name;
public static void Main()
{
}
}
Whenever In the above example we can see that we have a class called Employee and it doesn't have any access modifier it means that it is an internal class.
And using System; is a root namespace.
Well done....sir
ReplyDeleteThanks a lot!
ReplyDeletePost a Comment