Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hi,

I want to change "I" to "K" where "I" is a string.
I was trying to convert "I" to int and increment the value to 2 and again convert it to "K" in C#.
I could see the exception.
Please help me in achieving a solution
Posted 24-Apr-13 2:45am
Comments
Member61 at 24-Apr-13 7:48am
   
What exception u r getting?
can you please paste here?
sri4dotnet at 24-Apr-13 7:58am
   
Actually it is related to Excel sheet, data is populated in "I" column but need to be populated in "K" column. I am able to retrieve the column value as "I" and trying to convert it to int and increment to 2 and again convert it to string. so that I can get "K".

This is code,
string a = row[1].ToString();
int column = Convert.ToInt32(a);

where in a, I get the value as "I"

Exception is "Input string was not in a correct format".
ThePhantomUpvoter at 24-Apr-13 8:12am
   
Don't you think that is need-to-know information? Whatever "a" is cannot be converted to an int which is exactly what the error is telling you.
Member61 at 25-Apr-13 0:42am
   
Are u looking for ASCII values?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

string k, i;
k = "1";
i = "2";
i = (Convert.ToInt32(i) + 2).ToString();
k = i;
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 255
1 Suvendu Shekhar Giri 215
2 Andy Lanng 210
3 PIEBALDconsult 190
4 Abhinav S 184
0 Sergey Alexandrovich Kryukov 6,310
1 OriginalGriff 5,853
2 Peter Leow 2,484
3 Maciej Los 2,263
4 Abhinav S 2,249


Advertise | Privacy | Mobile
Web01 | 2.8.150414.1 | Last Updated 24 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100