错误'由于其保护级别而无法访问 - Unity

时间:2018-01-16 10:55:37

标签: c# unity3d

我在Visual Studio(使用Unity)(C#版本7.2)上收到此错误:

  

Volume / BuilderInstance.cs(32,32):错误CS0122:由于其保护级别(CS0122),“懒惰”无法访问

这是代码:

using System;

namespace ConvNetSharp.Volume {

public class BuilderInstance<T> where T : struct, IEquatable<T>, IFormattable {
    public static readonly Lazy<VolumeBuilder<T>> Singleton = new Lazy<VolumeBuilder<T>>(Create);
    public static VolumeBuilder<T> Volume { get; set; } = Singleton.Value;

    public static VolumeBuilder<T> Create() {
        if (typeof(T) == typeof(double)) {
            return (VolumeBuilder<T>)(object)new Double.VolumeBuilder();
        }
        if (typeof(T) == typeof(float)) {
            return (VolumeBuilder<T>)(object)new Single.VolumeBuilder();
        }
        throw new NotSupportedException(
            $"Volumes of type '{typeof(T).Name}' are not supported. Only Double and Single are supported.");
    }
}

}

我在Lazy变量声明中得到错误! 为什么?有什么建议吗?

由于

0 个答案:

没有答案