📜  c# foreach char in string - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:19.702000             🧑  作者: Mango

代码示例1
const string value = "abc";
        // 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]);
        }