0

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 by mohit.choudhary: n/a

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by __avd
0

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

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.