几周前,我从Java切换到C#.今天,我有一个奇怪的行为,我尝试在这个简单的样本中重现它.我正在使用.net FW 4.
我有三个类:第一个是抽象的:
namespace ReadonlyStaticOrder
{
using System;
using System.Collections.Generic;
public abstract class AbstractClass
{
public AbstractClass(string value, IEnumerable<string> someValues)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
if (someValues == null)
{
throw new ArgumentNullException("someValues");
}
// would do something after...
}
}
}
Run Code Online (Sandbox Code Playgroud)
第二个 :
namespace ReadonlyStaticOrder
{
using System.Collections.Generic;
public sealed class ReadonlyOrderInitialization : AbstractClass
{
// this line introduces the bug, since it call the ctor before SomeValues already initialized
// if removed, …Run Code Online (Sandbox Code Playgroud)