空字符串 [英] Empty string

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

问题描述

你知道在你发现自己不知道之前你是怎么认识的。


好​​吧,我输入了一个函数定义...,new String( "))。


我知道我想要什么。阅读此内容的每个人都知道我想要什么。但是,

1.0编译器不知道我想要什么。


任何人都可以与我分享实际沟通的语法
$ b请给$ b概念编译器?


thx

md


***通过Developersdex发送< a rel =nofollowhref =http://www.developersdex.comtarget =_ blank> http://www.developersdex.com ***

You know how you assume you know until you find out you don''t know.

Well, I typed into a function definition "..., new String("")).

I know what I want. Everyone reading this knows what I want. However,
the 1.0 compiler has no idea what I want.

Can anyone share with me the syntax that will actually communicate the
concept to the compiler, please?

thx
md

*** Sent via Developersdex http://www.developersdex.com ***

推荐答案

其实我不确定你想要完成什么。使用new String()创建一个新的
字符串自动创建零长度字符串。

为什么要使用引号?


最好的问候

Johann Blake

Actually I''m not sure what you want to accomplish. Creating a new
string with "new String()" automatically creates a zero length string.
So why use quotation marks?

Best Regards
Johann Blake


MD写道:
你知道在你发现自己不知道之前你是如何认识的。
好吧,我输入了一个函数定义...,new String("))。

我知道我想要什么。阅读本文的每个人都知道我想要什么。
然而,1.0编译器不知道我想要什么。

任何人都可以与我分享将实际传达
概念的语法请编译好吗?

通过开发者指南发送 http://www.developersdex.com ***
You know how you assume you know until you find out you don''t know.

Well, I typed into a function definition "..., new String("")).

I know what I want. Everyone reading this knows what I want.
However, the 1.0 compiler has no idea what I want.

Can anyone share with me the syntax that will actually communicate the
concept to the compiler, please?

thx
md

*** Sent via Developersdex http://www.developersdex.com ***




为什么不使用" ?

创建一个你提供的新字符串对象有点过分了吗

a string-literal(也是一个字符串对象)你希望最终获得相同的价值...


你也可以使用预定义的常量String.Empty。


顺便说一句,1.1已经出来很长一段时间......


Hans Kesting



Why not use just "" ?
It''s a bit of overkill to create a new string-object that you supply with
a string-literal (which is also a string-object) that has exactly the same
value as you want to end up with...

You could also use the predefined constant String.Empty.

By the way, 1.1 has been out for quite some time ...

Hans Kesting


我第二个,使用常量String.Empty,而不是使用魔法

值。这只是更好的练习。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Hans Kesting" <是ne *********** @ spamgourmet.com>在消息中写道

news:eT ************** @ TK2MSFTNGP12.phx.gbl ...
I second this, use the constant String.Empty, instead of using a magic
value. It''s just better practice.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:eT**************@TK2MSFTNGP12.phx.gbl...
MD写道:
你知道在你发现自己不知道之前你是如何认识的那样。

好吧,我输入了一个函数定义...,new String(" ;))。

我知道我想要什么。阅读本文的每个人都知道我想要什么。
然而,1.0编译器不知道我想要什么。

任何人都可以与我分享将实际传达
概念的语法请编译好吗?

通过开发者指南发送 http://www.developersdex.com ***
You know how you assume you know until you find out you don''t know.

Well, I typed into a function definition "..., new String("")).

I know what I want. Everyone reading this knows what I want.
However, the 1.0 compiler has no idea what I want.

Can anyone share with me the syntax that will actually communicate the
concept to the compiler, please?

thx
md

*** Sent via Developersdex http://www.developersdex.com ***



为什么不使用" ?
创建一个新的字符串对象有点过分,你提供了一个字符串文字(也是一个字符串对象)具有完全相同的值因为你想最终得到...

你也可以使用预定义的常量String.Empty。

顺便说一下,1.1已经出了很长一段时间了。 ..

Hans Kesting



Why not use just "" ?
It''s a bit of overkill to create a new string-object that you supply with
a string-literal (which is also a string-object) that has exactly the same
value as you want to end up with...

You could also use the predefined constant String.Empty.

By the way, 1.1 has been out for quite some time ...

Hans Kesting



这篇关于空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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