Ionică Bizău
Ionică Bizău

Reputation: 113455

Next letters as against a char variable

I have a char variable c and a TextBox textbox1 in my C# application. I want to do this:

textbox1.Text = (c + 2).ToString(); //this doesn't work, sure

For example:

c = 'b';
textbox1.Text = "d";

How can I do this?

Upvotes: 3

Views: 199

Answers (3)

NPSF3000
NPSF3000

Reputation: 2451

Not sure why everyone's casting to int...

textbox1.Text = ((char)(c + 2)).ToString();

Upvotes: 8

Amiram Korach
Amiram Korach

Reputation: 13296

textbox1.Text = ((char)(((int)c) + 2)).ToString();

Upvotes: 7

Rohit Vats
Rohit Vats

Reputation: 81253

Try this -

textbox1.Text = Convert.ToChar((int)c +2).ToString()

Upvotes: -4

Related Questions