KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In C#, what's the best way to get the 1st digit in an int? The method I came up with is to: turn the int into a string, get the 1st char of the string, and turn the char into an int. Like: int start = Convert.ToInt32(curr.ToString().Substring(0, 1)); While this does the job, it feels like there is probably a good, simple, math-based solution to such a problem. String manipulation feels clunky. Edit: Irrespective of speed differences, mystring[0] instead of Substring() is still just string manipulation
Tags (comma-separated)
Save Edits
Cancel