Results 1 to 3 of 3

Thread: A field initializer cannot reference the nonstatic field, method, or property..

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    3

    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.
    Last edited by gep13; Aug 4th, 2011 at 01:59 AM. Reason: Edited code tags

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: A field initializer cannot reference the nonstatic field, method, or property..

    Welcome to the forums. can you please entire code ?
    Please mark you thread resolved using the Thread Tools as shown

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width