I think, this code is a result of Reflector disassembling :-D
cybertone
Posts
-
From the C# forum -
FTW?By the way, C# compiler (with optimization option 'on') generates these IL instructions for set accessor:
ldarg.0
ldarg.1
stfld bool <reference_to_local_field>
ret; so, at the C# level it whould be:
this._<reference_to_local_field> = value;
; So, this construction is obviously needless :-D
modified on Monday, January 19, 2009 1:56 AM
-
ToolStripMenuItem.Owner vs ContextMenuStripYes... item.Owner isn't ContextMenuStrip - it's type is ToolStripDropDownMenu. :suss: Construction like item.OwnerItem.Owner is not comprehensible, because: 1) It works for 2 level menu only, not for 3+ 2) For first level it throws exception Certainly, it is possible to use construction like:
ToolStripItem parent = item; while(parent.OwnerItem != null) parent = parent.OwnerItem; ContextMenuStrip menu = (ContextMenuStrip)parent.Owner;
... but it looks not as it would be desirable.
P.S. What for the reference to object which property item.Owner (on 2+ level) refers is necessary to me? :confused: -
ToolStripMenuItem.Owner vs ContextMenuStripYesterday i've received an interesting "feature"(or bug?). My form has context menu (ContextMenuStrip) with two levels: menuItem_1 -> menuItem_1_1 -> menuItem_1_2 menuItem_2 every menu item has
Click
event handler:void MenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; ContextMenuStrip menu = item.Owner as ContextMenuStrip; MessageBox.Show(menu == null ? "false" : "true"); }
I've got: menuItem_1 click => true menuItem_1_1 click => false menuItem_1_2 click => false menuItem_2 click => true So, ToolStripMenuItem's Owner on 2+ level is not a ContextMenuStrip!!! :eek: Is it normal? I bet - not... And how I can receive the reference to the ContextMenuStrip to which the 2+ level menu item belongs? :confused: -
Type conversion strange bugYesterday I've caught a very strange bug float a = 81.1666641F; float b = 18F; float c = 6.3166666F; float d = (a - b) / c; int e = (int)((a - b) / c); int f = (int)d; Console.WriteLine(d); Console.WriteLine(e); Console.WriteLine(f); -------------------------- OUTPUT: 10.0 9 10
-
Type conversion strange bugYesterday I've caught a very strange bug float a = 81.1666641F; float b = 18F; float c = 6.3166666F; float d = (a - b) / c; int e = (int)((a - b) / c); int f = (int)d; Console.WriteLine(d); Console.WriteLine(e); Console.WriteLine(f); -------------------------- OUTPUT: 10.0 9 10 :~
-
System.Reflection.Emit.EventBuilderI haven't any problem with Emit technology, excepting EventBuilder class. It's simple to create an "event" as ilasm does (using delegate field, public methods add_* and remove_*)... but it isn't an event(Type.GetEvent(...) returns null)! EventBuilder perfoms three interesting methods - SetAddOnMethod, SetRemoveOnMethod and SetRaiseMethod. And... what's the methods body should be? ILasm way? If yes, how can I get a delegate field for EventBuilder based event?
-
System.Reflection.Emit.EventBuilderDoes anybody know, how the System.Reflection.Emit.EventBuilder works? How can I define a simple event with it?