2 Ways to Search String in C# | IndexOf() vs Contains() in C#

preview_player
Показать описание
C# Tutorial for Beginners: There are 2 ways to search string in C#. IndexOf and Contains in C# both are used to search a string from another string in C#. The IndexOf method in C# is used to search any char or string in a given string. If a perfect match is found then the IndexOf method in C# will return the index otherwise the IndexOf method will return -1.
On the other hand the Contains() method in C# is also used to search the string in any given string but instead of returning the index, this Contains() method returns a boolean value. If the match is found then the Contains method in C# will return the true value otherwise false.
We can also implement the search by ignoring the case of string by passing StringComparion Enum. The StringComparison enum has multiple values and by passing StringComparison.InvarianCultureIgnoreCase

Chapters:
00:00 Introduction to search string in C#
00:30 IndexOf in C#
03:21 ignore case in IndexOf in C#
05:19 Contains in C#
05:58 Contains in C# with ignore case

#indexOfvsContains #string #csharp
Рекомендации по теме
Комментарии
Автор

Super, please make some practical task program.

priyaupadhyay