Click here to Skip to main content
15,916,379 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.

C#
using System.Text;

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

        }
Posted
Updated 19-Feb-11 17:48pm
v4

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.
C#
void Bend();
 
Share this answer
 
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
 
Share this answer
 
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
 
Share this answer
 
v2
Comments
Espen Harlinn 20-Feb-11 7:42am    
My 5
Sergey Alexandrovich Kryukov 20-Feb-11 14:12pm    
Thank you.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900