티스토리 뷰

Ongoing/String

for foreach [C#] string

More Code 2018. 6. 20. 19:37


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
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함