type
status
date
slug
summary
tags
category
icon
password
Property
Jul 24, 2023 02:56 AM

本节内容

表达式的定义
各类表达式概览
语句的定义
语句详解

表达式的定义

什么是表达式
  • 表达式是一种专门用来求值的语法实体。
  • Expressions, together eith commands and declarations,are one of the basic components of every programming language.We can say that expressions are the essential commponent of every language.
  • An expressions is a syntatic entity whose evaluation eithrt produces a value or fails to terminate, inwhich case the expression is undefined.
  • 各种编程语言堆表达式的实现不尽相同,但大体上都符合这个定义。
C#语言低表达式的定义
  • An expression is a sequence of one or more operators and zerp pr more operator that can be evaluated to a single value,object,method, or namespace. Expressions can consist of literal value, a method invocation, an operator and its operands, or a simple name. Simple names can be the name od a variable, type member, method parameter, namespace or type.
  • 算法逻辑的最基本(最小)单元,表达一定的算法意图
  • 因为操作符有优先级,所以表达式也就有了优先级

各类表达式概览

C#语言中表达式的分类
  • A value. Every value has an associated type.任何能得到值的运算(回顾操作符和结果类型)
  • A variable。Every variable has an associated type.
  • A namespace.
  • A type.
  • A method group.例如:Console.WriteLine,这是一组方法,重载决策决定调用哪一个
  • A null literal.
  • An anonymous function.
  • A property access.
  • An event access.
  • An indexer access.
  • Nothing. 对返回值为void的方法的调用。
复合表达式的求值
  • 注意操作符的优先级和同优先级操作符的运算方向
参考C#语言定义文档
  • 仅做参考,不必深究–毕竟我们是在学习语言,不是去实现这门语言
notion image
注意 三元?:最后获得的类型是精度高的类型。
C#知识学习—11 表达式,语句详解(2)C#知识学习—09 操作符详解(3)
  • Waline
Kitety
Kitety
独特为佳
公告
我曾经七次鄙视自己的灵魂
--卡里·纪伯伦
第一次,当它本可进取时,却故作谦卑;
第二次,当它在空虚时,用爱欲来填充;
第三次,在困难和容易之间,它选择了容易;
第四次,它犯了错,却借由别人也会犯错来宽慰自己;
第五次,它自由软弱,却把它认为是生命的坚韧;
第六次,当它鄙夷一张丑恶的嘴脸时,却不知那正是自己面具中的一副;
第七次,它侧身于生活的污泥中,虽不甘心,却又畏首畏尾。
 
最新评论
Loading...