English 中文(简体)
匿名开端是否优先于违约,或是在违约之后吗?
原标题:Do anonymous initializes override defaults, or are they run after?

如果我有一个缺省的初步策划人,并在我提出反对时确定匿名。 缺省是否ski过,或刚刚发生? 我想知道的理由是,在下文中,如果这些物体在之后运行,就会立即放弃在违约时产生的清单物体,从而造成不必要的垃圾。

class ArrangedPanel : RectElement
{
    public List<RectElement> arrangedChildren = new List<RectElement>();
    public int Padding = 2;
}

//Somewhere else
new ArrangedPanel() 
{ 
   Padding = 5,
   arrangedChildren = new List<RectElement>()
   {
      new ButtonToggle(),
      new ButtonToggle()
   }
}
最佳回答

在你的例子中,<代码> 婚内=2 ,在<条码>之前发生。

你并不一定要创立一个<代码>List<RectElement>,但我对你提出挑战,在这种不必要拨款造成任何可观的业绩打击的情况下,这样做。

问题回答

。 最后,你将给你创造的榜样。

例如:

arrangedChildren = new List<RectElement>();
arrangedChildren = new List<RectElement>()
   {
      new ButtonToggle(),
      new ButtonToggle()
   }

the arrangedChildren will point to the second list. If no other object references to the first one it will disapair (GC). But if some 1 would keep a reference to the first instance it will stay alive and you could have duplicates or two differents lists where you are working on.

这可能造成一些问题。

http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf

The instance field variable initializers of a class correspond to a sequence of assignments that are executed immediately upon entry to any one of the instance constructors (§17.10.2) of that class. The variable initializers are executed in the textual order in which they appear in the class declaration. The class instance creation and initialization process is described further in §17.10.

因此,将首先进行身体类别申报的初始化,然后在建筑商进行初步化。 可以通过查看IL的产出来直接观察这一点。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签