Classes Object and Methods :

  • In OOP language it is must to create a class for representing data.
  • Class contains variables for storing data and functions to specify various operation that can be performed on data .
  • Class will not occupy any memory space and hence it is only represent of data .

  • How to write a class :

    class <classname > {
    class scanftree {
    	int p;
    	string s;
    	public void Test() {
    		Console .WriteLine(“scanftree”);

    create object for the class

    Scanftree obj;
    Obj=new scaftree();

    Program for class :

    using System ;
    using System.Collection.Generic ;
    using System.Linq ;
    using System .Text;
    namespace Oopprograme {
    	class Class1 {
    		public int year = 2011;
    		public string s= “scanftree”;
    		static void Main() {
    			Class1 cls=new Class1();
    			Console.WriteLine (“--------”+cls.s+”-------“);