What is happing is complicated (and very, very silly)
foreach
loops round providing one at a time each of the items in the list of items to teh right of the
in
keyword. Each time round, the item is provided in the variable v which is declared on the left side of the
in
keyword.
In you case, km.ToSting() returns a
string
, which when treated as an iterator =by anything (including
foreach
) retunrs a sequence of
char
- so:
foreach (char c in "hello")
{
Console.WriteLine(c);
}
Would give you:
h
e
l
l
o
Your code forces the
char
to be a
decimal
so each digit in the original
decimal
value is handed to you as a
decimal
in v. Your number in txtKMPerHr.Text starts with '2', so the first value passed to the loop is 50 - ASCII value of the character '2'
As I said - very silly. But what of earth are you trying to do that you think that this would help? :laugh: