anjum hayat

anjum hayat

  • NA
  • 1
  • 0

need help

Apr 7 2007 3:13 AM
hi,
im new in c# . i want to know that can a class and  its function can have same name. if yes then y? i have saw in a tutorial available on "http://csharpcomputing.com/Tutorials/Lesson4.htm".

using System;
class Demo
{
   public class animal
   {
      int weight;
      string name;
      public void show()
      {
         Console.WriteLine ("{0} has weight {1}", name, weight);
      }
      public void my_set (int k, string z)
      {
         weight=k;
         name=z;
      }
   }
   public class tiger:animal
   {
      public tiger()
      {
         my_set(100,"tiger");
         show();
      }
   }

   public class
lion:animal
   {
      public lion()
      {
         my_set(200,"lion");
         show();
      }
   }
    public static void Main()
   {
      tiger Mike = new tiger();
      lion Bob = new lion();
   }
}


Answers (1)