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
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 Apr 24, 2013, 4:02 AM EDT
string s = "I";
s = new string(new char[]{(char)(s[0] + 2)});
Console.WriteLine(s); // K
This should also work:
s = ((char)(s[0] + 2)).ToString();
srinath133 reputationPosted Apr 24, 2013, 6:26 AM EDT