Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0
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
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
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;

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

  Print Answers RSS
0 OriginalGriff 645
1 Maciej Los 225
2 Abhinav S 171
3 Richard Deeming 160
4 Suvendu Shekhar Giri 159
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 9,135
2 Peter Leow 5,042
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,581

Advertise | Privacy | Mobile
Web03 | 2.8.150327.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