e.g
int a=10;
string b="abc"
a = a+ b;
is it possible???
how???
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 18, 2013, 3:08 AM EDT
However, the following does work:
The result is 2758.
The reason this works is because "abc" can be parsed to an hexadecimal integer which is equivalent to 2748 decimal. So adding 10 gives a result of 2758.
arslan elahi21 reputationPosted Mar 18, 2013, 3:11 AM EDT
i want to convert it in C#
VulpesRank #55 · 29.2K reputationPosted Mar 18, 2013, 3:19 AM EDT
compiles OK with Option Strict Off but produces a run time exception because "abc" can't be parsed to a double.
arslan elahi21 reputationPosted Mar 18, 2013, 3:55 AM EDT
int a=10;
object b="abc";
a=a+ Convert.ToInt32(b.toString());
it is working
VulpesRank #55 · 29.2K reputationPosted Mar 18, 2013, 8:48 AM EDT
However, if you specify that the string represents a hexadecimal number, then it will work as the code is equivalent to what I posted in the first place: