|
Il presente articolo è stato tradotto automaticamente. Passare il puntatore sulle frasi nell'articolo per visualizzare il testo originale. Ulteriori informazioni.
|
Traduzione
Originale
|
Metodo String.StartsWith (String)
Spazio dei nomi: System
Assembly: mscorlib (in mscorlib.dll)
Parametri
- value
- Tipo: System.String
Stringa da confrontare.
Valore restituito
Tipo: System.Boolean| Eccezione | Condizione |
|---|---|
| ArgumentNullException |
using System; public class EndsWithTest { public static void Main() { // process a string that contains html tags // this sample does not remove embedded tags (tags in the middle of a line) string [] strSource = { "<b>This is bold text</b>", "<H1>This is large Text</H1>", "<b><i><font color=green>This has multiple tags</font></i></b>", "<b>This has <i>embedded</i> tags.</b>", "<This line simply begins with a lesser than symbol, it should not be modified" }; Console.WriteLine("The following lists the items before the tags have been stripped:"); Console.WriteLine("-----------------------------------------------------------------"); // print out the initial array of strings foreach ( string s in strSource ) Console.WriteLine( s ); Console.WriteLine(); Console.WriteLine("The following lists the items after the tags have been stripped:"); Console.WriteLine("----------------------------------------------------------------"); // print out the array of strings foreach ( string s in strSource ) Console.WriteLine( StripStartTags( s ) ); } private static string StripStartTags( string item ) { // try to find a tag at the start of the line using StartsWith if (item.Trim().StartsWith("<")) { // now search for the closing tag... int lastLocation = item.IndexOf( ">" ); // remove the identified section, if it is a valid region if ( lastLocation >= 0 ) item = item.Substring( lastLocation + 1 ); } return item; } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (ruoli di base del server non supportati), Windows Server 2008 R2 (ruoli di base del server supportati con SP1 o versione successiva, Itanium non supportato)
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.