Home > DeveloperSection > Blogs > Example of namespace

Example of namespace


C# C# 
Ratings:
0 Comment(s)
 158  View(s)
Rate this:

Example of namespace


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

{

    public class Class1

    {

        // fields

        protected int _id;

        protected string _name;

        protected string _phone;

        protected double _money;

 

        // properties

 

        public int id

        {

            get

            {

                return _id;

            }

            set

            {

                _id = value;

            }

        }

        public string name

        {

            get

            {

                return _name;

            }

            set

            {

                _name = value;

            }

        }

        public string phone

        {

            get

            {

                return _phone;

            }

            set

            {

                _phone = value;

            }

        }

        public double 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  class Class2

    {

        static void Main(string[] args)

        {

            Class1 c = new Class1();

 

            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.


Don't want to miss updates? Please click the below button!

Follow MindStick