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

Edited 6 Years Ago by mohit.choudhary: n/a

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

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!

This article has been dead for over six months. Start a new discussion instead.