본문 바로가기

Ongoing/String

for foreach [C#] string


using System;

namespace Console1
{
class Program
{
static void Main(string[] args)
{
string words = "Hello";

foreach (var c in words)
{
Console.WriteLine(c);
}
}
}
}

/* Output
H
e
l
l
o
*/



using System;

namespace Console1
{
class Program
{
static void Main(string[] args)
{
string words = "Hello";

for (int i = 0; i < words.Length; i++)
{
Console.WriteLine(words[i]);
}
}
}
}

/* Output
H
e
l
l
o
*/


'Ongoing > String' 카테고리의 다른 글

[C#] Composite Format String & Interpolated String  (0) 2018.07.09
for [C/C++] char[] string  (0) 2018.06.21
for [Java] String  (0) 2018.06.20
for [Python] string  (0) 2018.06.20
IO Functions [C] Character & String  (0) 2018.06.15