- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# String Methods
The String class has many methods that help you in working with the string objects. The following table has some of the most commonly used methods −
Sr.No | Method & Description |
---|---|
1 | public static int Compare(string strA, string strB) Compares two specified string objects and returns an integer that indicates their relative position in the sort order. |
2 | public static int Compare(string strA, string strB, bool ignoreCase ) Compares two specified string objects and returns an integer that indicates their relative position in the sort order. However, it ignores case if the Boolean parameter is true. |
3 | public static string Concat(string str0, string str1) Concatenates two string objects. |
4 | public static string Concat(string str0, string str1, string str2) Concatenates three string objects. |
5 | public static string Concat(string str0, string str1, string str2, string str3) Concatenates four string objects. |
6 | public bool Contains(string value) Returns a value indicating whether the specified String object occurs within this string. |
7 | public static string Copy(string str) Creates a new String object with the same value as the specified string. |
8 | public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count) Copies a specified number of characters from a specified position of the String object to a specified position in an array of Unicode characters. |
9 | public bool EndsWith(string value) Determines whether the end of the string object matches the specified string. |
10 | public bool Equals(string value) Determines whether the current String object and the specified String object have the same value. |
11 | public static bool Equals(string a, string b) Determines whether two specified String objects have the same value. |
Let us see an example to work with Contains() method in C#. The Contains(string value) returns a value indicating whether the specified String object occurs within this string.
Example
using System; namespace Demo { class Program { static void Main(string[] args) { string str = "This is test"; if (str.Contains("test")) { Console.WriteLine("Yes, 'test' was found."); } Console.ReadKey() ; } } }
- Related Articles
- Different methods to reverse a string in C/C++
- Python String Methods ?
- Java String Methods
- Java String Comparison Methods.
- What are jQuery string methods?
- String Methods in Dart Programming
- 5 Different methods to find length of a string in C++?
- Count consonants in a string (Iterative and recursive methods) in C++
- Java String replace(), replaceFirst() & replaceAll() Methods
- Java String toUpperCase() and toLowerCase() methods
- Built-in String Methods in Python
- 5 Different methods to find the length of a string in C++?
- Java methods to convert Double to String
- C# Anonymous Methods
- Name some of the string methods in javascript?

Advertisements