0

I am looping character through a memo field but I do not know how to stop the looping. Is there an End-of-field value like the EOF character? Is there a better way to determine the end of a memo field?

Oak Bytes
  • 4,649
  • 4
  • 36
  • 53

2 Answers2

1

If you use foreach you don't need to worry about it...

        string memo = "test";
        foreach (var x in memo.ToCharArray())
        {
            // you code here
        }
James Allen
  • 819
  • 7
  • 12
1

I'm not sure what you mean by a "memo field." Do you mean a string? If so, then you can access the Length property:

string memo = "hello, world";
for (int i = 0; i < memo.Length; ++i)
{
    char c = memo[i];
    // do what you want with the character.
}

Or you can use the foreach as was suggested previously:

foreach (var c in memo)
{
    // do what you want with the character
}
Jim Mischel
  • 131,090
  • 20
  • 188
  • 351