How to know if a string starts with certain characters

2

Does anyone know how I can know if a string starts with: for example ca if there is any function for this.

Example:

string cadena = "test";
string comienza = "te";
    
asked by Raidel Fonseca 24.10.2018 в 00:54
source

1 answer

8

Use the StartsWith function of the string class

string cadena = "test";
string comienza = "te";

if (cadena.StartsWith(comienza))
{
    //la cadena si comienza 
}
    
answered by 24.10.2018 / 00:57
source