I want to convert the following string
to an array of an integral number type.
string str = "-9007199254740985";
I tried str.ToArray().ToString();
but did not get the right conversion.
If you want to convert the string
to an array, you can do it like this.
var array = new string[] { str };
However, if you want an array of long
, you have to convert your string
first.
var number = long.Parse(str);
Then you can add it to an array.
var array = new long[] { number };
Note that you cannot use an int
here, because your number exceeds its range .
Below code will convert the string to character array.
string input = "welcome";
char[] chars = input.ToCharArray();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.