12 Sep 2017

what is class with Example

what is class

Class is a collection of data member and member function in an objected programming language. Data member is just like Data type and Member function 
just like a method of class. 

Some points of class:-

Class is a user define datatype,

Class is a Keyword,

Class is a Contener,

Class is a blue print,

Write A Simple Program a Class- Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Class
{
    class Animal
    {
        public string name = "Digveshwar";
        public int Age = 24;
        public void Print()
        {
       Console.WriteLine("Enter the Value of Nmae :" +name);
        Console.WriteLine("Enter the value of Age :" + Age);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Animal obj = new Animal();
            obj.Print();
            Console.ReadKey();  
        }
    }

}


Read Complete

10 Sep 2017

How to use switch case in c sharp


Switch case program-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Switch_case_program
{
    class Program
    {
        static void Main(string[] args)
        {
            int weekday;
            Console.Write("enter the Weekday :");
            weekday = Convert.ToInt16(Console.ReadLine());
            switch (weekday) 
            {
                case 1:
                    Console.Write("\nSunday");
                    break;

                case 2:
                    Console.Write("\nMonday");
                    break;

                case 3:
                    Console.Write("\nTuesday");
                    break;

                case 4:
                    Console.Write("\nWednesday");
                    break;

                case 5:
                    Console.Write("\nFriday");
                    break;

                case 6:
                    Console.Write("\nSaturday");
                    break;

                default :
                    Console.Write("invalid choies");
                    break;
            }
            Console.ReadKey();
        }
    }
}
Out Put :

Enter the value of 3



Enter the value of 4


Read Complete

Popular Posts

Popular Posts

Translate

Total Pageviews