what is the equivalent of lblconteo.Text = Len (txtMessage.Text); in c #?

0

I have this method to count the number of characters typed and it is in Visual Basic

lblconteo.Text = Len(txtMensaje.Text);

as you would in c #?

    
asked by Rodrigo Rodriguez 20.10.2017 в 17:13
source

3 answers

3

Use the property .Length that gives you the number of characters in a String :

lblconteo.Text = txtMensaje.Text.Length.ToString();

Note that you have to use ToString() since the property .Length is of type Int32 and lblconteo.Text accept String .

    
answered by 20.10.2017 / 17:16
source
1
int conteo = txtMensaje.Text.Length;

Greetings

    
answered by 20.10.2017 в 17:17
0

You can get the number of characters using the property Length and you can convert this value to String to use it in your label:

lblconteo.Text = txtMensaje.Text.Length.ToString();

Or also as another option:

lblconteo.Text = Convert.Tostring(txtMensaje.Text.Length);
    
answered by 21.10.2017 в 13:40