Error_1_'ConsoleApplication31.T'不包含'getdata'的定义,并且没有可以找到接受类型'ConsoleApplication31.T'的第一个参数的扩展方法'getdata'(您是否缺少using指令或程序集引用?)_ c :\用户 [英] 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

查看:97
本文介绍了Error_1_'ConsoleApplication31.T'不包含'getdata'的定义,并且没有可以找到接受类型'ConsoleApplication31.T'的第一个参数的扩展方法'getdata'(您是否缺少using指令或程序集引用?)_ c :\用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用System;

使用System.Collections.Generic;

使用System.Linq;

使用System.Text;

使用System.Threading.Tasks;



命名空间ConsoleApplication31

{

   界面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);

    }¥b $ b    R级
    {

$
    }


    T级:R,IEmployee

    {

        void IEmployee.getdata(int eno,string ename,double salary,int dno,string dname)

        {

            Console.WriteLine("输入员工编号:");

            eno = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("输入员工姓名:");

            ename = Console.ReadLine();

            Console.WriteLine("输入薪水:");

            salary = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("输入部门名称:");

            dname = Console.ReadLine();

            Console.WriteLine("输入部门号:");

            dno = Convert.ToInt32(Console.ReadLine());

        }¥b $ b        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);



        }¥b $ b    }


   课程计划

    {

        static void Main(string [] args)

        {

            T e = new T();

IEmployee ie = e;

            e.getdata();

            e.print();

        }¥b $ b    }
}


带下划线的错误


               

解决方案

有使用您已发布的代码多个问题:



  1. getdata 方法需要您未传递的参数
  2. getdata 方法只能使用
    类型的变量调用 IEmployee  ,但您尝试使用
    T 类型的变量调用它。  

你应该这样称呼:

 ie.getdata(" eno"," ; ENAME","工资"," DNAME"," DNO"); 




希望给你想法


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;
            e.getdata();
            e.print();
        }
    }
}

the error in the underlined lines

               

解决方案

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:

 ie.getdata("eno","ename","salary","dname","dno");

Hope that gives you idea.


这篇关于Error_1_'ConsoleApplication31.T'不包含'getdata'的定义,并且没有可以找到接受类型'ConsoleApplication31.T'的第一个参数的扩展方法'getdata'(您是否缺少using指令或程序集引用?)_ c :\用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆