C-sharper
C-sharper

Reputation: 110

Returning string is not successful

I have a problem which may look easy but I can't solve it.
I have a function which returns a string and has two arguments:

public string MyFunc(string ID, string TargetID)   // ID is 9999999995 and TargetID is 9999999998
{
    return ID + TargetID;    // Gives me ID only(9999999995).
}

When I try to put text instead of the ID, it works, but not with a number. I've tried to use StringBuilder but I get the same result.

I use it like this:

MessageBox.Show(MyFunc(Settings.Default.ID, ComboBox1.Text));

Upvotes: 1

Views: 79

Answers (3)

C-sharper
C-sharper

Reputation: 110

Thank you everybody, but the problem was in receiving the string from netStream, That was my fault. When sending the string I haven't added the "$" char in the end and so the string maybe was so long or something...

Upvotes: 0

Nisha
Nisha

Reputation: 1853

Check the values are not null to be safe and do a String.Concat(...)

Upvotes: 1

user1548266
user1548266

Reputation:

The function is working as intended. Check that the incoming parameters ID and TargetID actually contain values and they are the values you expect.

Upvotes: 2

Related Questions