I would like to have a reference to a byte as a class member, but it shows me an error invalid token 'ref' in class member declaration
any workaround?
class MCP
{
public byte olRegister;
};
class IO
{
byte --reference to olRegister--;
};
I would like to have a reference to a byte as a class member, but it shows me an error invalid token 'ref' in class member declaration
any workaround?
class MCP
{
public byte olRegister;
};
class IO
{
byte --reference to olRegister--;
};
You can't do that in C#
One possible solution would be to wrap your byte in a reference type, create an instance of it, and inject it into an instance of MCP
and IO
.
public class Wrapped<T> where T: struct
{
public Wrapped(T t)
{
Elem = t;
}
public T Elem { get; set;}
}
class MCP
{
public Wrapped<byte> McpByte { get; set; }
};
class IO
{
public Wrapped<byte> IoByte { get; set; }
};
var b = new Wrapped<byte>(someByte);
var mcp = new Mcp { McpByte = b };
var io = new Io { IoByte = b };
mcp.McpByte = someOtherByte;
Assert.Equal(someOtherByte, io.IoByte);
This might not be the best solution - but we can't tell without knowing more about the bigger picture.