Hello Everybody,
Iam not able to figure out why iam getting the following error:

Error 1:Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Error 2: Invalid Expression term '='
Error 3: ; expected

Iam only trying to append "1" to string m_strTime.

public partial class TimerGUI : Form
    {
        private String m_strTime = "";

       ....
       .....

        private void button1_Click(object sender, EventArgs e)
        {
            m_strTime  + =   "1";        //<---------ERROR
           .....
           ..........

But if i do this

m_strTime  = m_strTime + "1";

Then i dont get errors.

Thanks In Advance

pls try this

#
private void button1_Click(object sender, EventArgs e)
#
{
#
m_strTime += "1";
//no need of space between + and = will be the pblm i think.


Hello Everybody,
Iam not able to figure out why iam getting the following error:

Error 1:Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Error 2: Invalid Expression term '='
Error 3: ; expected

Iam only trying to append "1" to string m_strTime.

public partial class TimerGUI : Form
    {
        private String m_strTime = "";

       ....
       .....

        private void button1_Click(object sender, EventArgs e)
        {
            m_strTime  + =   "1";        //<---------ERROR
           .....
           ..........

But if i do this

m_strTime  = m_strTime + "1";

Then i dont get errors.

Thanks In Advance

+= is an operator (string concatenates).

string greet="He";
greet += "llo";

Thank you very much. Yes it worked. Have a wonderful day.

You're welcome. I'm glad you got it working. Please mark this thread as solved if you have found an answer to your question and good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.