C#访问者“获取”返回 [英] C# Accessors "Get" return

查看:54
本文介绍了C#访问者“获取”返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么C#需要一个get {}中的return语句?}

您是否想要返回一些内容并不明显?



谢谢

解决方案

这个问题与询问完全相同:所有非空函数都需要返回'语句?你想要归还的东西不是很明显吗?



换句话说,这个问题缺乏基本逻辑。是的,从功能或财产的签名中可以明显看出返回的需要(同样,在这方面没有区别)。但这还不够。应该返回什么价值以及在什么时候?这由 return语句表示。



此外,这个问题意味着在声明和定义之间以及声明和声明之间没有区别。语言(以及C#返回派生自的语言)不是声明性语言。语句实际上编写了一些操作,这些操作确实发生在计算机寄存器,内存或端口上。如果你使用参数和返回类型声明一些函数,最终定义需要使用这些参数指定一些操作并将返回值或对象赋值给某些东西。



-SA

Hi, How come C# requires a "return" statement within a get{} ??
Isn't it obvious that you would want to return something?

thanks

解决方案

This question is exactly the same as asking: "how come 'return' statement is required for all non-void functions? Isn't it obvious that you would want to return something?"

In other word, this question lacks elementary logic. Yes, a need for return is obvious from the signature of a function or a property (again, there is no difference in this respect). But this is not enough. What value should be returned and at what point? This is expressed by the return statement.

Also, this question means seeing no difference between declaration and definition, and also between declaration and statement. The language (as well as the languages where C# return was derived from) is not a declarative language. Statements actually code some action, something really happening to the computer registers, memory or ports. If you declare some function with, say, arguments and return type, eventually the definition needs to specify some action using these parameters and assignment return value or object to something.

—SA


这篇关于C#访问者“获取”返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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