Error_1_'ConsoleApplication31.T' does not contain a definition for 'getdata' and no extension method 'getdata' accepting a first argument of type 'ConsoleApplication31.T' could be found (are you missing a using directive or an assembly reference?)_c:\user RRS feed

  • Question

  • using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace ConsoleApplication31
        interface IEmployee
            void getdata(int eno, string ename, double salary, int dno, string dname);
            void print(int eno, string ename, double salary, int dno, string dname);
        class R


        class T : R, IEmployee
            void IEmployee.getdata(int eno, string ename, double salary, int dno, string dname)
                Console.WriteLine("Enter the employee no:");
                eno = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the employee name:");
                ename = Console.ReadLine();
                Console.WriteLine("Enter the salary:");
                salary = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("Enter the department name:");
                dname = Console.ReadLine();
                Console.WriteLine("Enter the department no:");
                dno = Convert.ToInt32(Console.ReadLine());
            void IEmployee.print(int eno, string ename, double salary, int dno, string dname)
                Console.WriteLine("eno:" + eno);
                Console.WriteLine("ename:" + ename);
                Console.WriteLine("salary:" + salary);
                Console.WriteLine("dname:" + dname);
                Console.WriteLine("dno:" + dno);


        class Program
            static void Main(string[] args)
                T e = new T();
    IEmployee ie = e;

    the error in the underlined lines

    Tuesday, October 16, 2018 12:08 PM

All replies

  • There are multiple problems with the code that you have posted :

    1. getdata method expects parameters that you are not passing
    2. getdata method can only be called with variable of type IEmployee  but you are trying to call it with variable of type T. 

    You should be calling it like:


    Hope that gives you idea.

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered"Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Blog | LinkedIn | Stack Overflow | Facebook
    profile for Ehsan Sajjad on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, October 16, 2018 12:16 PM
  • Hi sandcastle18,

    //the error in the underlined lines

    Because it is a explicit implementation of an interface, which is not public, and we could not call it from T's instance. we need to call it from interface's instance. like this:

    IEmployee ie = new T();
    ie.getdata(related parameters)

    For more information, please refer to:


    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, October 17, 2018 7:14 AM