J
Jeff0803
Guest
I declared Rectangle as nullable(Rectangle?) for some reason.
I need to change the value of it but compile error occurs.
class Square : IDraw, IColor
{
private int sideLength;
private int locX = 0, locY = 0;
private Rectangle? rect = null;//Rectangle is a struct, so use a nullable
public Square(int sideLength)
{
this.sideLength = sideLength;
}
void IDraw.Draw(PictureBox picturebox)
{
if (this.rect != null)
{
// do something later!
}
else
{
this.rect = new Rectangle();
}
this.rect.Value.Height = this.sideLength; // Error occur here!!!
// do something more later!
}
.
.
.
}
The error message is like following.
error CS1612: Cannot modify the return value of 'Rectangle?.Value' because it is not a variable
How to change the height of Rectangle?
Continue reading...
I need to change the value of it but compile error occurs.
class Square : IDraw, IColor
{
private int sideLength;
private int locX = 0, locY = 0;
private Rectangle? rect = null;//Rectangle is a struct, so use a nullable
public Square(int sideLength)
{
this.sideLength = sideLength;
}
void IDraw.Draw(PictureBox picturebox)
{
if (this.rect != null)
{
// do something later!
}
else
{
this.rect = new Rectangle();
}
this.rect.Value.Height = this.sideLength; // Error occur here!!!
// do something more later!
}
.
.
.
}
The error message is like following.
error CS1612: Cannot modify the return value of 'Rectangle?.Value' because it is not a variable
How to change the height of Rectangle?
Continue reading...