Q:

if statement in a foreach loop c#

I want to add an if statement in this foreach loop but it obviously throws up errors.

Too many characters in character literal

This is what I did and what i want to achieve with this. is there a way i can do this?
foreach (User user in this.oSkype.Friends)
        {
            if (user.OnlineStatus == 'olsOffline') {
                this.listBoxControl1.Items.Add(user.Handle + ' Offline');
            } else {
                this.listBoxControl1.Items.Add(user.Handle + ' Online');
            }
        }

A:

You dealing with type string not char. So update single quotes to double quotes:
foreach (User user in this.oSkype.Friends)
        {
            if (user.OnlineStatus == "olsOffline") {
                this.listBoxControl1.Items.Add(user.Handle + " Offline");
            } else {
                this.listBoxControl1.Items.Add(user.Handle + " Online");
            }
        }

