【发布时间】:2020-01-08 13:19:33
【问题描述】:
我正在阅读库代码,我看到了以下语法。我在 Google 上搜索了很多以找出语法名称,但我没有找到任何东西。任何帮助将不胜感激。
/// <summary>
/// Returns a singleton object that is used to manage the creation and
/// execution of setup
/// </summary>
/// <typeparam name="TMvxSetupSingleton">The platform specific setup singleton type</typeparam>
/// <returns>A platform specific setup singleton</returns>
protected static TMvxSetupSingleton EnsureSingletonAvailable<TMvxSetupSingleton>()
where TMvxSetupSingleton : MvxSetupSingleton, new()
{
// Double null - check before creating the setup singleton object
if (Instance != null)
return Instance as TMvxSetupSingleton;
lock (LockObject)
{
if (Instance != null)
return Instance as TMvxSetupSingleton;
// Go ahead and create the setup singleton, and then
// create the setup instance.
// Note that the Instance property is set within the
// singleton constructor
var instance = new TMvxSetupSingleton();
instance.CreateSetup();
return Instance as TMvxSetupSingleton;
}
}
请注意, new () {。这是什么意思?
【问题讨论】:
标签: c# syntax new-operator