[英]Type of conditional expression cannot be determined because there is no implicit conversion between 'int' and 'string'
pls any one here can help me fix this请这里的任何人都可以帮我解决这个问题
checked
{
foreach (string text2 in ParametersString)
{
int num = Conversions.ToInteger((!Versioned.IsNumeric(text2)) ? -1 : text2);
if (num == -1)
{
Interaction.MsgBox(string.Format("Entering characters is not allowed ---> {0}", text2), MsgBoxStyle.Critical, Class10.string_4);
}
else if (!this.method_2(num))
{
Interaction.MsgBox(string.Format("The specified port ({0}) is already in use", text2), MsgBoxStyle.Critical, Class10.string_4);
Environment.Exit(0);
}
else
{
this.Listener = new TcpListener(IPAddress.Any, num);
this.Listener.Server.SendTimeout = -1;
this.Listener.Server.ReceiveTimeout = -1;
this.Listener.Server.SendBufferSize = 999999;
this.Listener.Server.ReceiveBufferSize = 999999;
this.Listener.Start();
int num2 = 5;
string string_ = Class7.string_0;
if (Operators.CompareString(string_, "High", false) != 0)
{
if (Operators.CompareString(string_, "Normal", false) == 0)
{
num2 = 10;
}
else if (Operators.CompareString(string_, "Low", false) == 0)
{
num2 = 5;
}
}
else
{
num2 = 16;
}
int num3 = num2;
for (int j = 1; j <= num3; j++)
{
new Thread(new ThreadStart(this.ScanerAsync)).Start();
}
int num4 = num2;
for (int k = 1; k <= num4; k++)
{
new Thread(new ThreadStart(this.method_1)).Start();
}
text += Conversions.ToString(num);
this.closing = false;
}
}
Class6.string_0 = text;
}
Error in line线路错误
int num = Conversions.ToInteger((!Versioned.IsNumeric(text2)) ? -1 : text2);
Error :错误 :
Type of conditional expression cannot be determined because there is no implicit conversion between 'int' and 'string'无法确定条件表达式的类型,因为“int”和“string”之间没有隐式转换
Type of conditional expression cannot be determined because there is no implicit conversion between 'int' and 'string'无法确定条件表达式的类型,因为“int”和“string”之间没有隐式转换
This means that return type of !Versioned.IsNumeric(text2)) ? -1 : text2
这意味着!Versioned.IsNumeric(text2)) ? -1 : text2
返回类型!Versioned.IsNumeric(text2)) ? -1 : text2
!Versioned.IsNumeric(text2)) ? -1 : text2
can't be narrowed to single type. !Versioned.IsNumeric(text2)) ? -1 : text2
不能缩小为单一类型。 It is either int ( -1
) or string ( text2
).它是 int ( -1
) 或 string ( text2
)。
int num = Conversions.ToInteger((!Versioned.IsNumeric(text2)) ? "-1" : text2);
Now, in either case the result of the conditional tenary operator will be string现在,无论哪种情况,条件十元运算符的结果都将是字符串
int num = Versioned.IsNumeric(text2) ? Conversions.ToInteger(text2) : -1;
text2
is numeric then convert string to int如果text2
是数字,则将字符串转换为 inttext2
is not numeric then use -1
如果text2
不是数字,则使用-1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.