hi i'm a vb.net programmer trying to learn C# for now.
Let me ask you about simple questions in C#

How do you do this in C#?

this is a vb.net code:

TextBox1.Text = 1

Because the Text property of TextBox is of type string and not of type integer.
C# is very picky about this, and as a matter of fact this is one of the things I like about C# :)
Alternatively you could write: TextBox1.Text = 1.ToString();

Edited 5 Years Ago by ddanbe: n/a

Thanks for the replies.. How about if i wanted to delete the last text input in the textbox say for example the characters inside the textbox is: LATER. I want to remove the last letter R. How will i do this in C#?

Thanks for the replies.. How about if i wanted to delete the last text input in the textbox say for example the characters inside the textbox is: LATER. I want to remove the last letter R. How will i do this in C#?

Think about how you would do it in vb.net.... C# and VB.Net are built on the same framework, and have the same class hierarchy. The actual differences between the languages are very few, and mostly syntactical. One of the only legitimate differences is the ability to use pointers in an unsafe context in c# (even though this is still possible in vb.net via win32 api calls).

Edited 5 Years Ago by skatamatic: n/a

since the textbox is of type string, u can use the string class to manipulate and play with the values of a textbox, check for Replace(), SubString() or Remove() methods of the string class.

i tried this to no avail..

txtDisplay.Text = txtDisplay.Text.Remove((txtDisplay.Text.Length - 1), 1);
string strng;
int location;
if (txtDisplay.Text.Length > 0)
{
strng = txtDisplay.Text.Substring(txtDisplay.Text.Length - 1);
                if (strng == ".")
               {                  
               }
               location = txtDisplay.Text.Length;
               txtDisplay.Text = txtDisplay.Text.Remove(location - 1, 1);
            }

if u have to remove the last character, you can use Substring() method

txtDisplay.Text = "123456";

txtDisplay.Text = txtDisplay.Text.Substring(0, txtDisplay.Text.Length - 1);
//now the text becomes "12345"
This question has already been answered. Start a new discussion instead.