Problems with struct properties...
Hello everyone. I am using structs for the first time, and I am getting an error when I compile. The error is in this code here:
Code:
foreach (ThumbStruct x in this.ThumbArray)
{
x.Thumb.Dispose();
x.Index = 0; //Underlines the 'Index' part as being wrong.
x.Path = ""; //Underlines the 'Path part as being wrong.
}
The two errors are the exact same, and they read: "The left-hand side of the assignment must be a variable, property, or indexer" The code it underlines is the x.Index assignment and the x.Path assignment (commented in the code above). The funny thing is, elsewhere in my code I use the same code to assign the variables in the struct using the properties. Anyone know why it is throwing this error?
Here is the struct code:
Code:
public struct ThumbStruct
{
private string sPath;
private int iIndex;
private System.Windows.Forms.PictureBox pbBox;
public string Path
{
get
{
return sPath;
}
set
{
sPath = value;
}
}
public int Index
{
get
{
return iIndex;
}
set
{
iIndex = value;
}
}
public PictureBox Thumb
{
get
{
return pbBox;
}
set
{
pbBox = value;
}
}
}