C# Querying With LINQ Querying the BirdWatcher Data Bird Search Extension

Aaron Selonke
Aaron 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
Steven Parker
163,444 Points

:point_right: This 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.