[已解决]编译错误:接口成员无法定义 [英] [Solved] Compile error: interface members cannot have a definition

查看:97
本文介绍了[已解决]编译错误:接口成员无法定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译错误:接口成员不能有定义-("bend"一词下呈蓝色波浪形)

从事家庭作业和谷歌搜索,但到目前为止还无法使任何工作正常.

Compile error: interface members cannot have a definition -- (there''s a blue squiggly under the word "bend")

Working on homework & googled but haven''t been able to make anything work so far.

using System.Text;

namespace IBendable
{
    public interface IBendable
    {
        void Bend()
        {

        }

推荐答案

void Bend(){}是具有函数定义的函数签名.花括号将函数定义为在此阶段不执行任何操作,但仍将其定义.尝试用分号结束函数签名.
void Bend(){} is a function signature with a function definition. The curly braces define the function to do nothing at this stage, but it is still defined. Try ending your function signature with a semi-colon.
void Bend();


我自己弄清楚了. ..这是我宁愿做的.

我在void Bend()之后添加了分号;
然后我删除了空虚处的2个弯曲部分.

现在没有错误,但是不会持续很长时间...大声笑
I figured it out on my own...which is what I would rather do.

I added a semi-colon after void Bend();
and I removed the 2 squigglies under void.

No errors now but that won''t last long...lol


您的目的是不使您的代码编译.您的问题表明,在撰写本文时,您不知道接口的用途.由于可能您仍然不知道,因此需要进一步学习.

请查看以下问题和解答:什么是使用抽象类和接口? [ http://msdn.microsoft.com/en-us/library/orm-9780596521066-01-13.aspx [
You purpose if not to make your code compile. Your question shows that at the moment of writing you has no idea of the purpose of interfaces. As it''s possible you still don''t, you need to learn it before you can go any further.

Please look at this Question and Answers: What is Use of Abstract class and Interface?[^] and read this, for starters: http://msdn.microsoft.com/en-us/library/orm-9780596521066-01-13.aspx[^].

Better yet, take a good manual and read doing simple exercises; this knowledge is very fundamental.

Please pardon me if you already understand all that, though an extra advice would not hurt. :)

—SA


这篇关于[已解决]编译错误:接口成员无法定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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