string - C# String Tips and Tricks

C# String Tips and Tricks

Posted on

This article provides Tips and Tricks for using string in C#.Net.

1. Passing Double Quotes (“) in C# String

Most of the applications are required to pass a string with double quotes to the sqlparameter to execute a stored procedure.

Output

string - C# String Tips and Tricks

2. C# string reverse

Unfortunately Reverse() function is not available in C# string class, so we can use following approach to reverse string:

Output

reverseString - C# String Tips and Tricks

3. Search string in c# RichTextBox

The Find method of the RichTextBox control searches for string given in the string parameter. If string found it returns the first character position of the search string in the RichTextBox. If the text is not found, the Find method returns -1. By specifying the same value for the start position and the end position, the Find() finds the entire string, starting from the zero position.

Output

search String - C# String Tips and Tricks

4. c# string split

This C# tip shows the string.Split method. It uses a character to split given string.

Output

stringsplit - C# String Tips and Tricks

Source techzoo.org