如果条件满足预期的表达式 [英] Expression expected on if condition

查看:103
本文介绍了如果条件满足预期的表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HeadersLiteral.Text = If(contentType IsNot Nothing ,  "Content-Type: " & contentType & "<br />", String.Empty))
            HeadersLiteral.Text += (If(contentTransferEncoding IsNot Nothing, "Content-Transfer-Encoding: " & contentTransferEncoding, String.Empty)



错误显示在if条件下.
任何人都请解决错误,然后进行更新.

错误:experssion期望



The error is shown on if condition.
Any one please solve the error and please make an update.

error: experssion expected

推荐答案

在"if"语句下期望布尔表达式:比较结果或布尔运算符的结果.那不是很自然吗?它应该是返回TrueFalse的东西.相反,您可以编写以,"(逗号)分隔的布尔表达式.逗号不是布尔运算符.

-SA
Under "if" statement Boolean expression is expected: result of comparison or result of Boolean operator. Isn''t that natural? It should be something returning True or False. Instead, you write Boolean expressions delimited by '','' (comma). Comma is not a Boolean operator.

—SA


If就像您在Excel中编写If语句一样显示:
If appears as if you wrote your If statements like you were writing them in Excel:
If(condition, returnIfTrue, returnIfFalse)



这不是VB.NET中的工作方式:



That''s not how it work in VB.NET:

If condition Then
    statementsIfTrue
Else
    statementsIfFalse
End If


这篇关于如果条件满足预期的表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆