简体   繁体   English

返回字符串不成功

[英]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. 当我尝试放置文本而不是ID时,它可以工作,但不能用数字。 I've tried to use StringBuilder but I get the same result. 我试过使用StringBuilder,但我得到了相同的结果。

I use it like this: 我这样使用它:

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

The function is working as intended. 该功能按预期工作。 Check that the incoming parameters ID and TargetID actually contain values and they are the values you expect. 检查传入参数IDTargetID实际包含值,它们是您期望的值。

检查值是不是null是安全的并做一个String.Concat(...)

Thank you everybody, but the problem was in receiving the string from netStream, That was my fault. 谢谢大家,但问题是从netStream接收字符串,这是我的错。 When sending the string I haven't added the "$" char in the end and so the string maybe was so long or something... 发送字符串时,我最后没有添加“$”字符,所以字符串可能太长了或者什么......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM