type
Post
status
Published
date
Jul 17, 2023
slug
C-sharp-leraning-expression-1
summary
C#知识学习—10 表达式,语句详解(1)
tags
CS
C#
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#语言定义文档
- 仅做参考,不必深究–毕竟我们是在学习语言,不是去实现这门语言

注意 三元?:最后获得的类型是精度高的类型。
- 作者:Kitety
- 链接:https://www.kitety.com/article/C-sharp-leraning-expression-1
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章

.png?table=block&id=596c7759-2fab-402a-a1de-c610a866d169&t=596c7759-2fab-402a-a1de-c610a866d169&width=1080&cache=v2)

.png?table=block&id=fa81f9ab-c0da-4f4e-a935-0567380c36d0&t=fa81f9ab-c0da-4f4e-a935-0567380c36d0&width=1080&cache=v2)
.png?table=block&id=55df38cd-a361-41ee-a75d-c17615e78d6b&t=55df38cd-a361-41ee-a75d-c17615e78d6b&width=1080&cache=v2)
_(1).jpg?table=block&id=a716c7ee-7105-4a3f-8133-a15129086419&t=a716c7ee-7105-4a3f-8133-a15129086419&width=1080&cache=v2)
.jpg?table=block&id=2e9784d9-1d6e-44fc-9106-f0c576ddcb8f&t=2e9784d9-1d6e-44fc-9106-f0c576ddcb8f&width=1080&cache=v2)

.png?table=block&id=c0772cdb-ee08-49f4-b2f3-c804586bb769&t=c0772cdb-ee08-49f4-b2f3-c804586bb769&width=1080&cache=v2)

.png?table=block&id=b43ea4ae-a57d-4962-80ba-12280979702b&t=b43ea4ae-a57d-4962-80ba-12280979702b&width=1080&cache=v2)
