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














Tags:

Replace string in C#[C#] Remove Last Character From StringC# foreach loopHow To Declare and access array of string in C#c# stringSplit String In C#.net String vs stringAsp.net Convert String To ImageC# Binary To StringC# Convert String To DateTimeConvert Array To Comma Separated String C#

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.