Click here to Skip to main content
15,893,588 members
Home / Discussions / C#
   

C#

 
GeneralRe: thoughts on localizing SQL exceptions? Pin
Member 232448318-Nov-08 10:15
Member 232448318-Nov-08 10:15 
GeneralRe: thoughts on localizing SQL exceptions? Pin
Wendelius18-Nov-08 10:34
mentorWendelius18-Nov-08 10:34 
QuestionSpecifying pointer address, or something like that... Pin
boberick218-Nov-08 8:08
boberick218-Nov-08 8:08 
AnswerRe: Specifying pointer address, or something like that... Pin
Dave Kreskowiak18-Nov-08 8:21
mveDave Kreskowiak18-Nov-08 8:21 
GeneralRe: Specifying pointer address, or something like that... Pin
boberick218-Nov-08 8:37
boberick218-Nov-08 8:37 
GeneralRe: Specifying pointer address, or something like that... Pin
Paul Conrad18-Nov-08 8:43
professionalPaul Conrad18-Nov-08 8:43 
QuestionWeakreference Pin
Seetha.R18-Nov-08 6:41
Seetha.R18-Nov-08 6:41 
AnswerRe: Weakreference [modified] Pin
Lutosław18-Nov-08 6:53
Lutosław18-Nov-08 6:53 
This is the idea of weak references. Citing MSDN:
"A weak reference allows the garbage collector to collect an object while still allowing an application to access the object. If you need the object, you can still obtain a strong reference to it and prevent it from being collected."
Your code is OK. Smile | :)

EDIT: I have tested your code and it works as expected. How did you make youre tests?
Like this?
static void Main(string[] args)
{
	TryWeakDictionary.WeakDictionary<int,> wd =
 new TryWeakDictionary.WeakDictionary<int,>();
	for (int i = 0; i < 100; i++) {
		wd.Add(i, new C { Data = "abc" });
	}
	GC.Collect();
	C v;
	if (wd.TryGetValue(0, out v))
		Console.WriteLine(v.Data);
	Console.WriteLine("End");
	Console.ReadLine();
}


Greetings - Gajatko

Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.

modified on Tuesday, November 18, 2008 1:25 PM

AnswerRe: Weakreference Pin
Guffa18-Nov-08 11:55
Guffa18-Nov-08 11:55 
GeneralRe: Weakreference Pin
Seetha.R18-Nov-08 22:42
Seetha.R18-Nov-08 22:42 
QuestionHow to learn computer name? Pin
Sokka9318-Nov-08 5:46
Sokka9318-Nov-08 5:46 
AnswerRe: How to learn computer name? Pin
Giorgi Dalakishvili18-Nov-08 6:07
mentorGiorgi Dalakishvili18-Nov-08 6:07 
AnswerRe: How to learn computer name? Pin
Sokka9318-Nov-08 6:40
Sokka9318-Nov-08 6:40 
Questionweb service Pin
netJP12L18-Nov-08 5:16
netJP12L18-Nov-08 5:16 
AnswerRe: web service Pin
Ennis Ray Lynch, Jr.18-Nov-08 5:28
Ennis Ray Lynch, Jr.18-Nov-08 5:28 
AnswerRe: web service Pin
Wendelius18-Nov-08 5:39
mentorWendelius18-Nov-08 5:39 
GeneralRe: web service Pin
netJP12L18-Nov-08 6:04
netJP12L18-Nov-08 6:04 
GeneralRe: web service [modified] Pin
Wendelius18-Nov-08 6:24
mentorWendelius18-Nov-08 6:24 
GeneralRe: web service Pin
netJP12L18-Nov-08 7:26
netJP12L18-Nov-08 7:26 
Questionbinary trees and traverse Pin
nesfrank18-Nov-08 5:06
nesfrank18-Nov-08 5:06 
AnswerRe: binary trees and traverse Pin
Pedram Behroozi18-Nov-08 5:59
Pedram Behroozi18-Nov-08 5:59 
AnswerRe: binary trees and traverse Pin
Alan Balkany19-Nov-08 3:53
Alan Balkany19-Nov-08 3:53 
GeneralRe: binary trees and traverse Pin
nesfrank19-Nov-08 8:12
nesfrank19-Nov-08 8:12 
GeneralRe: binary trees and traverse Pin
Alan Balkany19-Nov-08 8:17
Alan Balkany19-Nov-08 8:17 
QuestionDebug Statements - writing to the console and files Pin
stormydaniels18-Nov-08 4:18
stormydaniels18-Nov-08 4:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.