.net 备注字段中的最后一个字符
我正在通过备忘录字段循环字符,但我不知道如何停止循环。是否有类似EOF字符的字段结束值?有没有更好的方法来确定备注字段的结尾?如果您使用.net 备注字段中的最后一个字符,.net,loops,special-characters,memo,.net,Loops,Special Characters,Memo,我正在通过备忘录字段循环字符,但我不知道如何停止循环。是否有类似EOF字符的字段结束值?有没有更好的方法来确定备注字段的结尾?如果您使用foreach您不需要担心它 string memo = "test"; foreach (var x in memo.ToCharArray()) { // you code here } 我不知道你所说的“备注字段”是什么意思。你是指字符串吗?如果是,则可以访问Leng
foreach
您不需要担心它
string memo = "test";
foreach (var x in memo.ToCharArray())
{
// you code here
}
我不知道你所说的“备注字段”是什么意思。你是指字符串吗?如果是,则可以访问
Length
属性:
string memo = "hello, world";
for (int i = 0; i < memo.Length; ++i)
{
char c = memo[i];
// do what you want with the character.
}
我不熟悉foreach函数。foreach的目标是什么?你能给我举个例子吗?为什么使用
ToCharArray
?
foreach (var c in memo)
{
// do what you want with the character
}