Accessing a member on Form may cause a runtime exception because it is a field of a marshal-by-reference class

前端 未结 4 422
别跟我提以往
别跟我提以往 2020-12-17 10:32

Accessing a member on Form may cause a runtime exception because it is a field of a marshal-by-reference class

I know what this warnin

4条回答
  •  不知归路
    2020-12-17 10:54

    Or you can write:

    var obj = new Remotable();
    
    Console.WriteLine(((int) obj.field).ToString());     // No warning
    

    Here you take your own responsibility for that cast (unboxing).

提交回复
热议问题