a を列挙したいのですstring
が、それを返す代わりにchars
、反復変数を type にしたいと思いますstring
。これはおそらく反復型にすることはできないstring
ので、この文字列を反復する最も効率的な方法は何ですか?
ループの反復ごとに新しいstring
オブジェクトを作成する必要がありますか、それとも何らかの方法でキャストを実行できますか?
String myString = "Hello, World";
foreach (Char c in myString)
{
// what I want to do in here is get a string representation of c
// but I can't cast expression of type 'char' to type 'string'
String cString = (String)c; // this will not compile
}