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 trialStepas Loiba
11,180 PointsOverride the Scan method to return true if any value in the array is a repeat of the value immediately preceding it.
Can some one have look in code and give few pointers why i have error message error CS1525: Unexpected symbol )', expecting
.',thank you in advance.
namespace Treehouse.CodeChallenges
{
class SequenceDetector
{
public virtual bool Scan(int[] sequence)
{
return true;
}
}
}
namespace Treehouse.CodeChallenges
{
class RepeatDetector : SequenceDetector
{
public override bool Scan(int[] sequence)
{
foreach(int sequance in int)
{
int i = 1;
if(sequence[i] == sequence[i - 1])
{
return true;
}
else
{
return false;
}
}
}
}
}
2 Answers
Steven Parker
231,269 PointsIt looks like you have the right basic idea.
Perhaps you only need a few hints:
- your foreach expression syntax is not correct — but you don't really need foreach here
- you can make use of more of your existing code with a simple for loop
- remember not to "
return false
" until the entire loop has finished checking for duplicates
I'll bet you can get it from here.
Stepas Loiba
11,180 PointsThank you Steven again:) you helping me a lot.have nice day.very helpful post.