Hey guys,
I need to find the length of a long variable (how many numbers it holds).
So if the variable holds: '1234567890' then I want to return an int value
of '10'. varName.Length() doesn't work, and I haven't found anything from
google or msdn.

Thanks for the help,

- WolfShield

I need to find the length of a long variable (how many numbers it holds). So if the variable holds: '1234567890' then I want to return an int value
of '10'.

One way to do this is with Math.Log10. There's a trick to getting the right answer, though... look at the example output on the linked page for clues.

@Mitja Bonca:
Your answer does not solves the question.
Your string length is 10, while the equivalent long length is only 9.

int length = myLongVar.ToString().Length;

Thanks you! Works like a charm!

- WolfShield

This question has already been answered. Start a new discussion instead.