We have a arbitrary array of title for books or other stuff. We want to get the first title that the program can find from our own search query.1

Step 1

Create a array of string and fill it with arbitrary book titles.

Step 2

Create a new method (it need to be static2) that need the array and an extra string (the search query) as parameter.

It should return you the first appearence of a matching title string and if none was found it returns an empty string.

Hint: To test if a string contains another string use the Contains()3 method. This method is case sensetiv!

Step 3

Change the Main method to the new algorithm.

The user should enter a arbitrary search query. The programm only accept a search query if it has more than 2 characters in it.4

Step 4

If a title was found it should be printed on the console. Else the programm should print “No title was found.”.

  1. You can find the solution to this task Here.

  2. We discuss static in a different lesson. So be patient ;)

  3. MSDN Site for stringobject.Contains()

  4. You can get the length of a string with the Length property of the string. (MSDN Site)