
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
String class in C#
The string keyword is an alias for the System.String class. The String class has the following two properties −
Sr.No. | Property & Description |
---|---|
1 | Chars Gets the Char object at a specified position in the current Stringobject. |
2 | Length Gets the number of characters in the current String object. |
The following are some of the methods of String class −
Sr.No. | Methods & 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. |
Let us see how to create a string and join a string in the following example −
Example
using System; namespace StringApplication { class StringProg { static void Main(string[] args) { string[] starray = new string[]{"Cricket is my life", "It is played between two teams", "It has three formats", "T20, Test Cricket and ODI", "Cricket is life" }; string str = String.Join("\n", starray); Console.WriteLine(str); } } }
- Related Questions & Answers
- String Template Class in C#
- C++ string class and its applications?
- String class in Java
- C++ Program string class and its applications?
- String Template Class in Python?
- Java String Class Tutorial
- Difference between String class and StringBuffer class in Java
- Class in C#
- What is Java String Class?
- Debug Class vs Debugger Class in C#
- How to use the Compare method of the string class in C#?
- BigInteger Class in C#
- Stack Class in C#
- Static class in C#
- Singleton Class in C#
Advertisements