Click here to Skip to main content
15,896,382 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Comments
Rockstar_ 24-Apr-13 7:48am    
What exception u r getting?
can you please paste here?
sri4dotnet 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".
[no name] 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.
Rockstar_ 25-Apr-13 0:42am    
Are u looking for ASCII values?

1 solution

C#
string k, i;
k = "1";
i = "2";
i = (Convert.ToInt32(i) + 2).ToString();
k = i;
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900