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

Chiroi Niehus
Chiroi Niehus
6,729 Points

Having Trouble on Code Challenge: Virtual Methods

I am having trouble on the code challenge 'Virtual Methods'. When I run my code, I get the errors: RepeatDetector.cs(9,26): error CS0029: Cannot implicitly convert type System.Random' toint' RepeatDetector.cs(9,47): error CS0019: Operator -' cannot be applied to operands of typeSystem.Random' and `int'

I know why I am getting these errors, but I can't figure out any other way to solve this code challenge.

Thanks in advance!

1 Answer

Mark Sebeck
MOD
Mark Sebeck
Treehouse Moderator 37,799 Points

Hi Chiroi. Without seeing your code it's hard to troubleshoot. Not sure what you are using system.random for.

I assume you are on part 3 of the challenge. I simply used a foreach loop to loop through the array. If int = previous int then I returned true. If not I set previous int equal to the int. Finally if the loop ends I return false since it didn't find anything.

Feel free to post your code if you are still having issues and I can help more. Good luck. Keep at it!