A field initializer cannot reference the nonstatic field, method, or property..
Hi,
I Working on Asp.net 2.0. I am declaring and initializing variables globally like this:-
Code:
double a1=0.0081;
double B3=12.61/100;
double B4=B3-a1;
double B5=B4-a1;
double B6=B5-a1;
double F8=Convert.ToDouble(TxtSqFeet.Text.ToString());
double F9=Convert.ToDouble(TxtLinealFeet.Text.ToString());
double G6=Convert.ToDouble(TxtTravelTime.Text.ToString());
double G11=Convert.ToDouble(TxtLiners.Text.ToString());
And find the following error:- A field initializer cannot reference the nonstatic field, method, or property..
Second Error is TxtSqFeet expect a class.
Please help me to resolve this error.
Re: A field initializer cannot reference the nonstatic field, method, or property..
Welcome to the forums. can you please entire code ?
Re: A field initializer cannot reference the nonstatic field, method, or property..
I have to agree with Dana, can you show your complete code? Specifically, where in the code file the above code is written?
I am assuming that TxtSqFeet and the others that you have are TextBoxes declared within your ASPX markup, right?
Gary