public DisposableWeakReference(IDisposable target) { if ((object)target == null) { throw new ArgumentNullException(nameof(target)); } this.hashCode = target.GetHashCode(); this.handle = GCHandle.Alloc(target, GCHandleType.Weak); }
static void Main(string[] args) { var p = string.Concat("To Box ou no box\t", 42 + "\t", true); //Boxing int int i = 42; object o = i; int x = (int)o; Console.WriteLine(p + "\n" + x); HttpClient client = new HttpClient(); object oc = client; IDisposable d = client; Console.WriteLine("\n {0} \t {1}", oc.GetHashCode(), d.GetHashCode()); Console.ReadKey(); }
private void CleanListBoxSelected(IDisposable actualListBox) { foreach (var listBox2 in Controls.OfType<Panel>().SelectMany(panel => panel.Controls.OfType<ListBox>().Where(xx => xx.GetHashCode() != actualListBox.GetHashCode()))){ listBox2.ClearSelected(); } }
public override int GetHashCode() { return(Object.GetHashCode()); }
public override int GetHashCode() => Value?.GetHashCode() ?? 0;