课程表

VB.Net基本教程

VB.Net高级教程

工具箱
速查手册

VB.Net - 其他操作符

当前位置:免费教程 » 程序设计 » VB.Net

有很少其他重要的操作系统支持VB.Net。

运算符描述示例
AddressOfReturns the address of a procedure.
返回过程的地址。
  1. AddHandler Button1.Click,
  2. AddressOf Button1_Click
AwaitIt is applied to an operand in an asynchronous method or lambda expression to suspend execution of the method until the awaited task completes.
它应用于异步方法或lambda表达式中的操作数,以挂起该方法的执行,直到等待的任务完成。
  1. Dim result As res
  2. = Await AsyncMethodThatReturnsResult()
  3. Await AsyncMethod()
GetTypeIt returns a Type object for the specified type. The Type object provides information about the type such as its properties, methods, and events.
它返回指定类型的Type对象。 Type对象提供有关类型的信息,例如其属性,方法和事件。
  1. MsgBox(GetType(Integer).ToString())
Function ExpressionIt declares the parameters and code that define a function lambda expression.
它声明定义函数lambda表达式的参数和代码。
  1. Dim add5 = Function(num As
  2. Integer) num + 5
  3. 'prints 10
  4. Console.WriteLine(add5(5))
IfIt uses short-circuit evaluation to conditionally return one of two values. The If operator can be called with three arguments or with two arguments.
它使用短路评估有条件地返回两个值之一。 可以使用三个参数或两个参数调用If运算符。
  1. Dim num = 5
  2. Console.WriteLine(If(num >= 0,
  3. "Positive", "Negative"))

示例:

以下示例演示了其中一些运算符:
  1. Module assignment
  2. Sub Main()
  3. Dim a As Integer = 21
  4. Console.WriteLine(GetType(Integer).ToString())
  5. Console.WriteLine(GetType(Double).ToString())
  6. Console.WriteLine(GetType(String).ToString())
  7. Dim multiplywith5 = Function(num As Integer) num * 5
  8. Console.WriteLine(multiplywith5(5))
  9. Console.WriteLine(If(a >= 0, "Positive", "Negative"))
  10. Console.ReadLine()
  11. End Sub
  12. End Module

当上述代码被编译和执行时,它产生以下结果:
  1. System.Int32
  2. System.Double
  3. System.String
  4. 25
  5. Positive
转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号