blog

Home / DeveloperSection / Blogs / Example of namespace

Example of namespace

Allen Scott1438 21-Jul-2016

Namespace is a container that takes class, interface, enum, structure and delegates. The class name declared in one namespace does not conflict with the same class names declared in another.

 Example of namespace

Create a class1.cs file and given to namespace name as mindstck 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace mindstick
{
    publicclassClass1
    {
        // fields
        protectedint _id;
        protectedstring _name;
        protectedstring _phone;
        protecteddouble _money;
 
        // properties
 
        publicint id
        {
            get
            {
                return _id;
            }
            set
            {
                _id = value;
            }
        }
        publicstring name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }
        publicstring phone
        {
            get
            {
                return _phone;
            }
            set
            {
                _phone = value;
            }
        }
        publicdouble money
        {                                          
            get
            {
                return _money;
            }
            set
            {
                _money = value;
            }
        }
 
    }
}

 

Create a another file class2.cs and import namespace mindstick

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using mindstick;
 
 
namespace OoopsConcepts
{
   public  classClass2
    {
        staticvoid Main(string[] args)
        {
            Class1 c = newClass1();
 
            c.id = 1001;         
            c.name = "Ashish";
            c.phone = "987456244";
            c.money = 4500;
            Console.WriteLine("Details of Employee:- " + c.id + " \n" + c.name + " \n" + c.phone + " \n" + c.money + "");         
            Console.ReadLine();
          
        }
    }
}

 

Output: Details of Employee:-1001

        Ashish

        987456244

        4500

 

Connection Oriented: 


In this case we required a connection with the data source for accessing


the data

 

 

Dataset: 


It is class present under System.Data” namespace. It is capable for holding


more than tables. It works on disconnected architecture that does not


required permanent connection. Dataset provide us index based access


data means we can get data from any location.

 

Data Adapter: 


Data Adapter is used to transfer data between dataset into database. It has


command like select, insert, update and delete. By default data adapter is


not support insert, update, delete.


Data adapter is acts as a mediator between database and dataset object.


It will acts as a Bridge between dataset and database

 

 

Data Reader: 


Data Reader is used to read the data from database and it is read and


forward only that connection oriented architecture during fetch the data


and It is used to result set that came from server and an it will read one by


one because of that memory consumption will be less and it will fetch that


data very fast when compared the dataset.


Updated 16-Mar-2018

Leave Comment

Comments

Liked By