Value was either too large or too small for an Int32. [Resolved]

Posted by Allemahesh under C# on 7/18/2013 | Points: 10 | Views : 35331 | Status : [Member] [MVP] | Replies : 3
I have 15 digit numeric number and I want to store in int type.
Like
string no = "854967458562031".
int str = Convert.ToInt32(no);
But I am getting error as Value was either too large or too small for an Int32.
Can any one help me




Responses

Posted by: Ssj_Kumar on: 7/18/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Int can hold the max values between 2,147,483,647 and -2,147,483,648, so try with long

Regards,
Jayakumar Selvakani

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 7/18/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Allemahesh,
Int 32 can hold only 10 digits
you can try int 64 its better


Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 7/18/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
string no = "854967458562031";
long str =Convert.ToInt64(no);
MessageBox.Show(str.ToString());

If this post helps you mark it as answer
Thanks

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response