解决 刚刚升级到福彩12选5走势图 5,我的静态int count变量不再初始化

银匠

活跃的成员
加入
3月7日,2020年
消息
44
编程经验
10+
因此,当我尝试在构造函数中使用它时,它会给这一个错误(它的null),这没有'T发生在福彩12选5走势图 4中所以我想知道它是否是它的核心功能或福彩12选5走势图 5,任何想法?
 
Last edited:

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,890
地点
切萨皮克,va.
编程经验
10+
I think you need to show us your code. An int can never be null.
 
Last edited:

银匠

活跃的成员
加入
3月7日,2020年
消息
44
编程经验
10+
嗨,这是代码;

错误发生在count ++时,它在福彩12选5走势图 4中完美工作

C#:
    class DrawBaseStream : DrawLine, IDrawStream, ISerializable
    {
        internal Guid startDrawObjectID, endDrawObjectID;
        internal DrawObject startObject, endObject;

        internal Guid startNodeGuid, endNodeGuid;
        internal Node startNode, endNode;
        static private int Count = 0;
    }
   
    public DrawBaseStream(Node hsstart, Node hsend) : base()
     {
         StreamColor = Color.Blue;
         Count++;
         Name = Count.ToString();
      }
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,890
地点
切萨皮克,va.
编程经验
10+
您还能与堆栈跟踪一起发布确切的异常吗?
 

jmplhinney.

C#论坛主持人
工作人员
加入
2011年4月23日
消息
3,720
地点
悉尼,澳大利亚
编程经验
10+
Hi heres the code;

错误发生在count ++时,它在福彩12选5走势图 4中完美工作

C#:
    class DrawBaseStream : DrawLine, IDrawStream, ISerializable
    {
        internal Guid startDrawObjectID, endDrawObjectID;
        internal DrawObject startObject, endObject;

        internal Guid startNodeGuid, endNodeGuid;
        internal Node startNode, endNode;
        static private int Count = 0;
    }
  
    public DrawBaseStream(Node hsstart, Node hsend) : base()
     {
         StreamColor = Color.Blue;
         Count++;
         Name = Count.ToString();
      }
您的构造函数似乎在它构造的课堂外面。这就是你发布了代码的方式吗?
 

jmplhinney.

C#论坛主持人
工作人员
加入
2011年4月23日
消息
3,720
地点
悉尼,澳大利亚
编程经验
10+
我刚刚在控制台应用程序定位福彩12选5走势图 Framework 4.8和福彩12选5走势图 5.0中测试了此代码:
C#:
class Program
{
    static void Main()
    {
        var t1 = new Thing();
        var t2 = new Thing();

        Console.WriteLine(t1.Name);
        Console.WriteLine(t2.Name);

        Console.ReadLine();
    }
}

class Thing
{
    private static int Count = 0;
    public readonly string Name;

    public Thing()
    {
        Count++;
        Name = Count.ToString();
    }
}
In both cases, it worked exactly the same way and exactly as you'd expect. I suspect that there's something else going on in your project and you just haven't debugged properly. As suggested, an int can't be null so, at the very least, your description is inaccurate.
 

银匠

活跃的成员
加入
3月7日,2020年
消息
44
编程经验
10+
Hi heres the code;

错误发生在count ++时,它在福彩12选5走势图 4中完美工作

C#:
    class DrawBaseStream : DrawLine, IDrawStream, ISerializable
    {
        internal Guid startDrawObjectID, endDrawObjectID;
        internal DrawObject startObject, endObject;

        internal Guid startNodeGuid, endNodeGuid;
        internal Node startNode, endNode;
        static private int Count = 0;
    }

    public DrawBaseStream(Node hsstart, Node hsend) : base()
     {
         StreamColor = Color.Blue;
         Count++;
         Name = Count.ToString();
      }

我刚刚在控制台应用程序定位福彩12选5走势图 Framework 4.8和福彩12选5走势图 5.0中测试了此代码:
C#:
class Program
{
    static void Main()
    {
        var t1 = new Thing();
        var t2 = new Thing();

        Console.WriteLine(t1.Name);
        Console.WriteLine(t2.Name);

        Console.ReadLine();
    }
}

class Thing
{
    private static int Count = 0;
    public readonly string Name;

    public Thing()
    {
        Count++;
        Name = Count.ToString();
    }
}
In both cases, it worked exactly the same way and exactly as you'd expect. I suspect that there's something else going on in your project and you just haven't debugged properly. As suggested, an int can't be null so, at the very least, your description is inaccurate.
是的,你当然是正确的。昨晚踩到代码时,这是似乎抛出错误的线路,今天早上看着它,实际上实现了它试图获得光标的线。

下面的这一行失败了并不完全确定为什么它以前是如此

C#:
private static Cursor handleCursor = new Cursor(typeof(DrawPolygon), "PolyHandle.cur");

将光标添加到资源后,用下一行替换它,并再次正常工作。

C#:
private static Cursor handleCursor = new(new System.IO.MemoryStream(Refbits.Properties.Resources.PolyHandle));
 
最佳 底部