I have two forms, in the first one, I declared an int variable that should filter the day of a List<DateTime>
, for example "Get all the dates that are on wednesday". This int is called WednesdayTotal
.
In form1, I placed a label and changed its text by WednesdayTotal
value, it displays "2", and I want to use that value in form 2, so the modifier of WednesdayTotal
is public, (because its just a test right now), and when I wanted to use it, it displays 0. Why?
Form1 Code:
public int WednesdayTotal;
WednesdayTotal = DateList.Count(x => x.DayOfWeek == DayOfWeek.Wednesday);
Form2 Code:
if (Home.WednesdayTotal >= 1)
{
WednesdayPin.Visible = true;
WednesdayValue.Visible = true;
WednesdayValue.Text = Home.WednesdayTotal.ToString();
}
In the following line:
WednesdayValue.Text = Home.WednesdayTotal.ToString();
displays the error:
Warning CS1690 Accessing a member on Form1.WednesdayTotal may cause a runtime exception because it is a field of a marshal-by-reference class