Delete characters from a string

Asked

Viewed 59 times

3

Hello, I have the following code snippet: agenciaModel.Bcx_Nome = agenciaViewModel.Bcx_Nome; to agenciaModel is sent to the api and sent to the banco de dados, but in the database the maximum string size is 35, as I can exclude the excess characters to 35?

In case you didn’t understand: I have a variable in my project that has no character limit, but when I send to the api this variable I want q to send only the 35 first characters, so there is no error when inserting in the bd, as I delete the rest of the characters from the string(the characters in excess of 35)?

1 answer

4


Use Substring:

string resultado = texto.Substring(0, 35);
  • 1

    It worked, thank you, when you give the time I accept the question

Browser other questions tagged

You are not signed in. Login or sign up in order to post.