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 trialAaron Selonke
10,323 Points.Contains Method used here
It looks like there is a String.Contains() method and an Enumerable.Contains() method that was introduced in this course.
She wants to use the String.Contains() here, but how does the compiler know which one that we are using. How does it know now to return true/false like the Enumerable.Contians() method?
2 Answers
Steven Parker
231,269 PointsThis is a basic OO concept known as polymorphism.
This particular type of polymorphism is called Method Overloading.
The correct Contains method is applied based on the type of object it is applied to, and the type and number of argument(s) given. Once the correct method is identified, that will also determine what kind of value is returned.
Aaron Selonke
10,323 PointsThanks