""没别的了 [英] "" and Nothing

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

问题描述

我的程序中有一个数组。 (声明为字母(16,16))。

当我在调试模式下暂停程序时,我在

汽车窗口中看到以下内容:
< br $> b $ b字母

| - (0,0)|什么都没有

| - (0,1)|什么都没有

I have an array in my program. (Declared as letters(16, 16)).
When I paused the program in debugging mode, I saw the following in the
Autos window:

letters
|- (0, 0) | Nothing
|- (0, 1) | Nothing

推荐答案

""是一个零长度的字符串。 String.Empty将返回此值。


赋值前字符串的值没有。

Dim s1 as string< - - s1的值为Nothing

Dim s2 as string = String.Empty


debug.writeline(s1.Length)< - 将导致null引用异常!!!

debug.writeline(s2.Length)< - 打印0

Greg


Xero < jeff _ @ _ chezjeff _._ net(remove_underscores_and_this)>在消息中写道

news:53 ********************************** @ microsof t.com ...
"" is a zero-length string. String.Empty will return this value.

Nothing is the value of a string prior to assignment.

Dim s1 as string <-- s1 has a value of Nothing
Dim s2 as string = String.Empty

debug.writeline(s1.Length) <-- will cause an null reference exception!!!
debug.writeline(s2.Length) <-- prints 0

Greg

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )> wrote in message
news:53**********************************@microsof t.com...
我的程序中有一个数组。 (声明为字母(16,16))。
当我在调试模式下暂停程序时,我在
Autos窗口中看到以下内容:

字母
| - (0,0)|什么都没有
| - (0,1)|什么都没有



| - (4,5)| "
| - (4,6)| "

""

没别的了?谢谢。

-
Xero

http://www.chezjeff.net
我的个人门户网站
I have an array in my program. (Declared as letters(16, 16)).
When I paused the program in debugging mode, I saw the following in the
Autos window:

letters
|- (0, 0) | Nothing
|- (0, 1) | Nothing
.
.
.
|- (4, 5) | ""
|- (4, 6) | ""

What is the difference between "" and Nothing? Thanks.

--
Xero

http://www.chezjeff.net
My personal web portal



以这种方式思考...


当你声明一个变量但不初始化它时,变量将

指向一个尚未包含任何内容的已分配内存地址,所以

变量指向Nothing。


当你有一个或已经初始化的字符串变量,但是后来有

它的值设置为",String对象确实存在于内存中,并且

变量确实指向该字符串(所以它不是什么都没有),但字符串是

零长度或"。

在VB.NET中,将对象变量设置为Nothing与将其设置为
$相同b $ b Null。

" Greg Burns" < greg_burns@DONT_SPAM_ME_hotmail.com>在消息中写道

news:ON ************** @ tk2msftngp13.phx.gbl ...
Think of it this way...

When you declare a variable, but do NOT initialize it, the variable points
to an allocated memory address that does not yet have anything in it, so the
variable points to "Nothing".

When you have a string variable that is or was initialized, but then has
it''s value set to "", the String object does exist in memory and the
variable does point to that string (so it''s NOT nothing), but the string is
zero length or "".

In VB.NET setting an object variable to Nothing is the same as setting it to
Null.
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:ON**************@tk2msftngp13.phx.gbl...
""是一个零长度的字符串。 String.Empty将返回此值。

在赋值之前,字符串的值没有任何内容。

Dim s1 as string< - s1的值为Nothing
Dim s2 as string = String.Empty

debug.writeline(s1.Length)< - 将导致空引用异常!!!
debug.writeline(s2。长度)< - 打印0
Greg

Xero < jeff _ @ _ chezjeff _._ net(remove_underscores_and_this)>在消息新闻中写道:53 ********************************** @ microsof t.com。 ..
"" is a zero-length string. String.Empty will return this value.

Nothing is the value of a string prior to assignment.

Dim s1 as string <-- s1 has a value of Nothing
Dim s2 as string = String.Empty

debug.writeline(s1.Length) <-- will cause an null reference exception!!!
debug.writeline(s2.Length) <-- prints 0

Greg

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )> wrote in
message news:53**********************************@microsof t.com...
我的程序中有一个数组。 (声明为字母(16,16))。
当我在调试模式下暂停程序时,我在
Autos窗口中看到以下内容:

字母
| - (0,0)|什么都没有
| - (0,1)|什么都没有



| - (4,5)| "
| - (4,6)| "

""

没别的了?谢谢。

-
Xero

http://www.chezjeff.net
我的个人门户网站
I have an array in my program. (Declared as letters(16, 16)).
When I paused the program in debugging mode, I saw the following in the
Autos window:

letters
|- (0, 0) | Nothing
|- (0, 1) | Nothing
.
.
.
|- (4, 5) | ""
|- (4, 6) | ""

What is the difference between "" and Nothing? Thanks.

--
Xero

http://www.chezjeff.net
My personal web portal




To过度简化,但得到的想法...

当你声明一个变量而不是初始化它时,如:

Dim s1 As String'' s1只是一个占位符,可以在某个时刻拿着一个字符串


就像清理桌面上的一个地方拿一张纸一样。

有实际上桌子上没有一张纸,所以没什么。


""表示空字符串。这就像一张白纸。那张纸是

,所以它肯定不是什么都没有,但纸上没有任何东西,

所以它是空的。

你可以同时声明和初始化变量,如:

Dim s2 As String = String.Empty''s2是一个字符串,但它是空的,或者是"


Gerald


" Xero" < jeff _ @ _ chezjeff _._ net(remove_underscores_and_this)>在消息中写道

news:53 ********************************** @ microsof t.com ...
To over-simplify, but get the idea across...
When you declare a variable and don''t initialize it, as in:
Dim s1 As String ''s1 is just a placeholder to hold a String at some point

It is like clearing a place on your desk to hold a piece of paper.
There is not actually a piece of paper on your desk, so there is Nothing.

"" means an empty string. This is like a blank piece of paper. The paper is
there, so it is definately not Nothing, but there is nothing on the paper,
so it is Empty.
You can declare and initialize a variable at the same time, as in:
Dim s2 As String = String.Empty ''s2 is a string, but it is empty, or ""

Gerald

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )> wrote in message
news:53**********************************@microsof t.com...
我的程序中有一个数组。 (声明为字母(16,16))。
当我在调试模式下暂停程序时,我在
Autos窗口中看到以下内容:

字母
| - (0,0)|什么都没有
| - (0,1)|什么都没有



| - (4,5)| "
| - (4,6)| "

""

没别的了?谢谢。

-
Xero

http://www.chezjeff.net
我的个人门户网站
I have an array in my program. (Declared as letters(16, 16)).
When I paused the program in debugging mode, I saw the following in the
Autos window:

letters
|- (0, 0) | Nothing
|- (0, 1) | Nothing
.
.
.
|- (4, 5) | ""
|- (4, 6) | ""

What is the difference between "" and Nothing? Thanks.

--
Xero

http://www.chezjeff.net
My personal web portal



这篇关于&QUOT;&QUOT;没别的了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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