c# - 使用正确的术语 : What is a "class reference" versus a "class variable"?

标签 c# oop

关闭。这个问题是opinion-based .它目前不接受答案。












想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题.

去年关闭。




Improve this question




为了确保在描述代码的某些方面时使用正确的术语,我要求澄清以下上下文中的使用:

如果我们写

int myIntTest;

我们说“我们有一个 int 变量”

假设我们有一个 Employee 类,当我们写
Employee myObjectTest;

我们说“我们有一个 Employee 对象的引用”

我的问题是:

说“myObjectTestEmployee 类的变量”是否正确?

最佳答案

我通常说“myObjectTest 是 Employee 类型的变量”,或者如果我想非常具体“myObjectTest 是一个引用 Employee 实例(或 null)的变量”。

我不确定是否有一个明确的答案。也许有人知道并且可以将您指向 specification 的正确部分。 :)

这是我发现的:

Types

Value types differ from reference types in that variables of the value types directly contain their data, whereas variables of the reference types store references to their data, the latter being known as objects.





Variables

Variables represent storage locations. Every variable has a type that determines what values can be stored in the variable.



因此,C# 规范似乎在谈论具有类型的变量。因此,“myObjectTest 是 Employee 类型的变量”与规范的语言相匹配。

关于c# - 使用正确的术语 : What is a "class reference" versus a "class variable"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60400749/

相关文章:

C#超时后自动释放锁

c# - 如何在 Entity Framework 中访问 c​​ontext.Database.SqlQuery?

javascript - 面向对象的 Javascript,为什么对象的方法不能在我的 init 方法中工作?

c# - 在 C# 中加速矩阵加法

c# - 提交使用没有用户名和密码的 Windows 帐户凭据的开发和生产连接字符串是否安全?

c# - 我可以将 null 作为 HashAlgorithm.TransformBlock() 的 "output buffer"参数传递吗?

javascript - 在 Javascript 中为派生类定义构造函数

c# - 使用一些默认值构建 XML 的最佳方法

c++ - C++ : classes vs. 结构中的抽象语法树

javascript - 从原型(prototype)方法更改实例属性