Sort String list with Numeric Values

前端 未结 3 1629
小鲜肉
小鲜肉 2021-01-17 23:55

I have a list of string, which is most likely, but not guaranteed to contain a list of numerics, i.e.,

{\"1\", \"6\", \"2\", \"21\", \"89\"}
3条回答
  •  一个人的身影
    2021-01-18 00:38

    If this is C#, that's what Int32.TryParse() is for.

    If this is C++, then std::string::find_first_not_of is a decent bet. Pass it a string containing the ascii chars for the digits 0 to 9 (plus the minus and plus signs?) and if it returns -1 then it is an integer.

提交回复
热议问题