Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collection is removed from memory after a while
Message
De
15/11/2013 14:26:07
 
 
À
15/11/2013 14:21:37
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:
01588067
Message ID:
01588087
Vues:
25
J'aime (1)
>>The answer is in the sample
>>
>>If TryGetValue() returns true, it was in
>>
>>There's also ContainsKey() - but TryGetValue() tells you whether the image was in and if it was returns the data via the out parameter
>>
>>http://msdn.microsoft.com/en-us/library/xfhwa508(v=vs.110).aspx
>
>Thanks, so you would recommand TryGetValue() instead of ContainsKey(). Is that correct?


Yes, because you directly have the width and the height afterwards - and your first message seems to use them
	class ImageData
	{
		internal int Width  { get; private set;}
		internal int Height { get; private set; }

		internal ImageData( int width, int height)
		{
		
			Width = width;
			Height = height;
		}
	}

	static  class TestImage
	{

		internal static void Go()
		{
			Dictionary<string, ImageData> images = new Dictionary<string,ImageData>();

			images.Add("image1", new ImageData(10, 20));
			images.Add("image2", new ImageData(30, 40));

			string s = "image1";

			bool found = false;
			ImageData imagedata;


			if (images.TryGetValue(s, out imagedata))
			{
				found = true;
				Console.WriteLine("Found {0} : Width {1} and Height {2}", found, imagedata.Width, imagedata.Height);
			}
			
		}
	}
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform