Char in string

In this chapter you will learn:

  1. Display all the characters in myString using a for loop

Get all characters

using System;//from j a  va2s .c o  m

class MainClass
{

  public static void Main()
  {
    string myString = "To be or not to be";

    
    for (int count = 0; count < myString.Length; count++)
    {
      Console.WriteLine("myString[" + count + "] = " + myString[count]);
    }

  }

}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. What are the methods we can use to compare strings
  2. Compare string case sensitively
  3. Compare string with start index and end index
  4. Compare strings using StringComparison enumeration: InvariantCulture
Home » C# Tutorial » String
string
String creation
Char in string
Compare strings
String equality
String concatanation
String copy
String Join
String split
String Search for Index
String contains
String start with
String insert
String case
Replacing substring
Remove from a string
Substring
Escape Characters
String verbatim
String padding
Switch on String
String trim
String intern
String normalization
Empty String