Field initializer cannot reference non-static field

后端 未结 1 959
没有蜡笔的小新
没有蜡笔的小新 2020-12-11 21:45

I have a class:

public class LED
{
    public System.Windows.Forms.Label lbl;

    public LED(System.Windows.Forms.Label lblLED)
    {
        lbl = lblLED;          


        
相关标签:
1条回答
  • 2020-12-11 22:31

    http://msdn.microsoft.com/en-us/library/5724t6za%28VS.80%29.aspx

    you cant use references to fields to initialize fields in the same class outside of a method, maybe because the order in which the reference variables are initialized is not guaranteed.

    0 讨论(0)
提交回复
热议问题