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 trialHarald Carlsten
7,806 Pointss => s.Length.IsEven(). I get a error message saying "Object does not contain a definition for "Length"".
In the last part of the video "Functional Programming", in the workshop "Extension methods", following along programming in Visual Studio, I get an error message saying "Object does not contain a definition for "Length" accepting a first argument of type "object" could be found (are you missing a using directive or an assembly reference). Someone knows why?
2 Answers
Steven Parker
231,248 PointsIn the video, "s" represents a string, but based on the error message you show here, it sounds like in your code it represents some other object which has no "Length" property.
For a complete analysis and more specific answer, show your entire code, or better yet, make a snapshot of your workspace and post the link to it here.
Harald Carlsten
7,806 PointsYes, you were right. I watched the Creating Datastructures - course and understood the mistake. It had put together the generic Random-method wrongly.
public static T GetRandomItem<T>(this List<T> list) { return list[_random.Next(0, list.Count())]; }
I didn't put the T on the right places and then the method generated an object instead of a string.