Solved

c#.net - setting a value to a variable---does a missing bracket cause this error?

Posted on 2011-09-25
4
157 Views
Last Modified: 2013-12-17
I get this error, maybe the braces are not matched up:

    string new_time_sent_range = null;

    new_time_sent_range = "l";

invalid token '=' in class, struct, or interface declaration
0
Comment
Question by:GlobaLevel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
Bill Nolan earned 500 total points
ID: 36596511
Your error is elsewhere.  Check the integrity of your class (esp. mismatched braces, missing semicolon, etc.)
0
 
LVL 14

Expert Comment

by:binaryevo
ID: 36596527
I concur with Slimfinger.  The code you provided looks fine...
0
 
LVL 12

Expert Comment

by:rajapandian_81
ID: 36597195
Hi,

You can not assign values to variable in class level. You can do only declaration. Modify the code like below:
    public partial class Form1 : Form
    {
        string new_time_sent_range = null;        

        public Form1()
        {
            InitializeComponent();
            new_time_sent_range = "l";

Open in new window

0
 
LVL 7

Expert Comment

by:Bill Nolan
ID: 36597427
Note: you can assign values at class level, but only in the initializer, such as:

string new_time_sent_range = "l";

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question