C # syntax line for int32 - value is too big

I get a string from an external interface that contains a value INT32. This value represents "-100" - a signed int - and therefore looks like this line "4294967196". If it was like -100, I could use Int32.TryParse()to pass it to the signed value. But in my case, he interprets the values ​​as they are and tells me that the value is too large (> 2.147.483.647). Any workaround to get this to work? How to tell the parser that lead 1 is not a number?

Edit: Sorry for the inaccuracy. The value I get is a string that looks like this: "4294967196". It represents Uint32with a value of -100. If the interface returns a string containing "-100", you can simply use it Int32.TryParse(). This is what I tried to express.

+3
source share
1 answer

Use uint.TryParse()and pass the result to int.

string s = "4294967196";
uint ux;
int x = 0;
if (uint.TryParse(s, out ux))
{
    x = (int)ux;
}
// x = -100
+10
source

All Articles