F D

F D

  • NA
  • 45
  • 80.4k

C sharp Constructor

Aug 11 2011 11:05 AM

When an object is created and call is made to the constructor what exactly is going on so that I have a great understanding? Need an explanation that will stick. Any ideas?

namespace EX12_1
{
    public class Fraction
    {
        private int numerator;
        private int denominator;

        public Fraction(int numerator, int denominator)
        {
            this.numerator = numerator;
            this.denominator = denominator;
        }
    }

 public class Test
  {
        public void Run()
        {
            Fraction firstFraction = new Fraction(3, 4);
            Console.WriteLine("\nfirstFraction: {0}", firstFraction.ToString());
        }
  }
 
  static void Main()
  {
            Test t = new Test();

           t.Run();
       
  } 
 
}   


Answers (5)