Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Out of memory on UCase()
Message
De
29/07/2013 14:02:19
 
 
À
29/07/2013 14:00:21
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01579306
Message ID:
01579370
Vues:
38
>Even better with an Enumerator - and ignoreCase if needed
>
>
>	public static class StringMethods
>	{
>		public static IEnumerable<int> EnumAt(string searchIn, string searchFor, int startIndex, StringComparison comparison)
>		{
>			int offset = startIndex;
>
>			while ((offset = searchIn.IndexOf(searchFor, offset, comparison)) != -1)
>			{
>				yield return offset;
>				offset += searchFor.Length;
>			}
>		}
>	}
>
>
>sample
>
>
>	public static class MyClass
>	{
>		static string htmlSample = @"
>		<!DOCTYPE html>
>
>		<html lang=""en-GB"">
>		<head>
>		  <meta charset=""utf-8"">
>		  <title>Example of an inline image</title>
>		</head>
>		<body>
>		<imG src=""balconyview.jpg"">
>		<Img Src = 'balconyview.jpg' alt='View from my balcony, showing a row of houses, trees and a castle'>
>		<iMg src='http://example.com/brokenlink/sunset.gif' alt='Beautiful Sunset' />
>
>		</body>
>		</html>
>		";
>
>		public static void Main()
>		{
>			foreach (int index in StringMethods.EnumAt(htmlSample, "<img", 0, StringComparison.InvariantCultureIgnoreCase))
>			{
>				Console.WriteLine("{0} {1}", index, htmlSample.Substring(index, 4));
>			}
>			Console.ReadLine();
>		}
>	}
>
Thanks, I will keep this as a reference.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform