Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Intermediate C# Polymorphism Virtual Methods

Can't get this to compile

Override the Scan method to return true if any value in the array is a repeat of the value immediately preceding it.

I just can't get this to compile!

SequenceDetector.cs
namespace Treehouse.CodeChallenges
{
    class SequenceDetector
    {
        public virtual bool Scan(int[] sequence)
        {
            return true;
        }
    }
}
RepeatDetector.cs
namespace Treehouse.CodeChallenges
{
    class RepeatDetector : SequenceDetector
    {
         public Overrride bool Scan(int[] sequence)
        {
           if (int i = 0; i <= sequence.Length; i++)
           {
               if (sequence[i].value == sequence[i-1].value)

           }
             return true;
        }
    }
}

3 Answers

You have some spelling errors. Change 'Overrride' to override and the first 'if' to 'for' where you have if (I =0....)

Actually, you have many mistakes. I suggest you watch the videos again!

Thanks

abduljabbar albehigi
PLUS
abduljabbar albehigi
Courses Plus Student 1,486 Points

I had problem with the logic, however I found some code that work and combined it here

namespace Treehouse.CodeChallenges { class RepeatDetector : SequenceDetector { public override bool Scan(int[] sequence) {

        for (int i = 1; i < sequence.Length; i++) 
           { 
                if (sequence[i - 1] == sequence[i])
                return true; 
           }

                return false;
    }
}

}