In VB.Net I made it like this :
lbl.Text +=1
is there any way, to make it one line in C# ?
Jarod
lbl.Text = (Convert.ToInt32(lbl.Text) + 1).ToString();
--
Tim Wilson
.Net Compact Framework MVP
"Jarod" <Ja...@discussions.microsoft.com> wrote in message
news:63AD492C-D188-48B6...@microsoft.com...
You can make it one line in C#, but it won't be as elegant:
// Increment the text of the label by adding one to the number that is on
the label.
lbl.Text = (++Convert.ToInt32(lbl.Text)).ToString();
The reason that works in VB is because it will perform automatic type
conversion. In reality, VB is converting the text to an integer,
incrementing it by 1, then converting back to a string, and then assigning
it back to the property.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Jarod" <Ja...@discussions.microsoft.com> wrote in message
news:63AD492C-D188-48B6...@microsoft.com...
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Nicholas Paldino [.NET/C# MVP]" <m...@spam.guard.caspershouse.com> wrote in
message news:%234uphmn...@TK2MSFTNGP10.phx.gbl...