Answers for "c# iterate through string"

C#
1

for loop string in c#

// Version 1: use foreach-loop.
foreach (char c in value)
{
	Console.WriteLine(c);
}
       
// Version 2: use for-loop.
for (int i = 0; i < value.Length; i++)
{
	Console.WriteLine(value[i]);
}
Posted by: Guest on August-10-2021
-1

c# iterate over string

// Regular Strings
string foo = "hello world", bar = string.Empty;

foreach(char c in foo){
    bar += c;
}

// StringBuilder
string foo = "hello world";
StringBuilder bar = new StringBuilder();

foreach (char c in foo)
{
    bar.Append(c);
}
Posted by: Guest on May-25-2020

Code answers related to "c# iterate through string"

C# Answers by Framework

Browse Popular Code Answers by Language