没有等于默认值吗? [英] Is Nothing equal to Default?

查看:34
本文介绍了没有等于默认值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 VB.NET 中将一个变量设置为空时会发生什么?真的没有什么等于默认,还是我在这里遗漏了什么?

What happens when i set a variable to nothing in VB.NET? Is it true that nothing equals to default, or am i missing something here?

推荐答案

如果是值类型(如 Integer、Double 等),将变量设置为 Nothing 会将其设置为默认值.

If it's a value type (like Integer, Double, etc.) setting the variable to Nothing will set it to the default value.

如果是引用类型,它真的会被设置为Nothing(空值).

If it's a reference type, it will really be set to Nothing (null value).

微软的话:

不给变量集赋值它的默认值声明类型.

Assigning Nothing to a variable sets it to the default value for its declared type.

如果变量是引用类型,值为 Nothing 意味着该变量与任何对象.变量为空价值.

If the variable is of a reference type, a value of Nothing means that the variable is not associated with any object. The variable has a null value.

这篇关于没有等于默认值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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