Smart    Lucky

Smart Lucky

  • NA
  • 538
  • 471.7k

Problem in Assigning one object to other object

Jun 17 2011 2:06 AM
Hi
i am trying to assign one object to other object but it is assigning and showing me this error can any one help me...?


Error1Cannot implicitly convert type 'DMLOperationOnArray.Test2' to 'DMLOperationOnArray.Test'D:\c# Prectice\DMLOperationOnArray\DMLOperationOnArray\Program.cs7017DMLOperationOnArray



using System;

namespace DMLOperationOnArray
{
    class Program
    {
        static void Main(string[] args)
        {
         Test t = new Test();
            t.Testmethod();
            Console.Write("\n\n\n");
            Test2 t2 = new Test2();
            t2.Testmethod2();
            t = t2; // error occured here
            Console.ReadKey();
        }
    }
    class Test
    {
        
        public void Testmethod()
        {
            int value = 20;
            Console.WriteLine(value);
        }
    }

    class Test2
    {
        public void Testmethod2()
        {
            int value = 40;
            Console.WriteLine(value);
        }
    }

}

Answers (4)