c# string

c# string 1. C# String
2. C# string array
3. c# string whitespaces
4. c# string immutable mutable
Done 5. c# string split
6. c# ConvertTostring()
7. c# string Replace()
8. c# string Concatinate()
9. C# string Builder()
10 c# string RegualrExpression
11 c# stringbuilder
12 C# SubString

Introduction

String is set of Unicode Characters. system.String is alias for String.


String first = "Hello";
String Second = "World";

String Third = first + Second;

Console.Write(Third);

OutPut:

HelloWorld


Escape sequence:

Prefix the string with @ sign if you wouldlike to use \ characters in string


String str = @"press back slash \ or new line \n";

or in VS 2010 you can write something like below.

String str = @"This is long string with multiple lines It is ok
to have it printed like this on next line
or code some ";



Double quote

To output string with double quote you can use forward slash ot quote

String str = "Mr. X said, \"Hellow, World \". " ;

Output:

Mr. X said, "Hellow, World ".


String is collectino of characters, you can iterate it like this also


string str = "Asp.net";

char c = str[4]

Console.WriteLine(c);

OutPut

c














Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5