Skip to content

Instantly share code, notes, and snippets.

@sapphire-al2o3
Created January 29, 2021 01:45
Show Gist options
  • Save sapphire-al2o3/f793f4b6e879b89e6ef7a08c45fd4e86 to your computer and use it in GitHub Desktop.
Save sapphire-al2o3/f793f4b6e879b89e6ef7a08c45fd4e86 to your computer and use it in GitHub Desktop.
部分文字列から数値をパースする
static int ParseInt(string t, int s, int l)
{
if (string.IsNullOrEmpty(t))
{
return 0;
}
if (s + l > t.Length)
{
l = t.Length - s;
}
int n = 0;
for (int i = s; i < s + l; i++)
{
n = n * 10 + t[i] - '0';
}
return n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment