Friday, October 4, 2013

Programming Example of creating class in C#

6:58 PM






C# Program to creating class 
In this csharp tutorial guideline while creating class
1. The class name should be noun and meaningful.
2. Use either pascal case or camel case. In camel case, the first letter is small. Ex. camelCase. In pascal case first letter is capital. Ex. PascalCase. It is strictly recommended you to use pascal case for class name and camel case for variable name.
3. Your class name should not contain any special character except underscore (_) or digit. Must start your class name with character.
4. Don’t use reserved keyword for class name.
Then we show the result in output
For this we use console readline and console write line



Program :

using System;


namespace Creating_Class

{
    class accept //Creating 1st. class
    {
        public string name;
        public void acceptdetails()
        {
            Console.Write("Enter your name:\t");
            name = Console.ReadLine();
        }
    }

    class print // Creating 2nd class

    {
        public void printdetails()
        {
            //Creating object of 1st. class
            accept a = new accept();
            //executing method of 1st class.
            a.acceptdetails();
            //Printing value of name variable
            Console.WriteLine("Your name is " + a.name);
        }
    }
    class Program //Creating 3rd class
    {
        static void Main(string[] args)
        {
            print p = new print();
            p.printdetails();
            Console.ReadLine();
        }
    }
}






  


output :













Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 comments:

Post a Comment

 

© 2013 1000TechTips. All rights resevered. Designed by Templateism

Back To Top