vb.net中的String.concat方法 [英] String.concat method in vb.net

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

问题描述






Concat恶化为

tmpStr = tmpStr.Concat(tmpStr,tmpStr2)


为什么它不引用所有者对象所以


tmpStr.Concat(tmpStr,tmpStr2)


和现在tmpStr与鞋面有相同的价值?


问候,jacky


Hi,

Concat wors as
tmpStr = tmpStr.Concat(tmpStr, tmpStr2)

Why it do not refer to owner object so

tmpStr.Concat(tmpStr, tmpStr2)

and now tmpStr has same value as upper?

Regards, jacky

推荐答案

" Jacky" < JA ****** @ hotmail.com> schrieb
"Jacky" <ja******@hotmail.com> schrieb

Concat恶化为
tmpStr = tmpStr.Concat(tmpStr,tmpStr2)


Concat是一个共享会员。 更好的语法是:


tmpStr = String.Concat(tmpStr,tmpStr2)


为什么它不引用所有者对象所以

tmpStr.Concat(tmpStr,tmpStr2)
现在和tmpStr有相同的值吗?

Concat wors as
tmpStr = tmpStr.Concat(tmpStr, tmpStr2)
Concat is a shared member. The "better" syntax is:

tmpStr = String.Concat(tmpStr, tmpStr2)

Why it do not refer to owner object so

tmpStr.Concat(tmpStr, tmpStr2)

and now tmpStr has same value as upper?




我希望我知道是什么你的意思是,但是如果我这样做,为什么你不要求这种语法:


tmpStr.Concat(tmpStr2)


你的版本包含tmpStr两次。


答案是字符串是不可变的。他们的内容不能改变。因此,您必须像第一个

版本一样进行任务。

-

Armin




I hope I know what you mean, but if I do, why don''t you ask for this syntax:

tmpStr.Concat(tmpStr2)

Your version contains tmpStr twice.

The answer is that Strings are "immutable". Their content can not be
changed. Consequently, you must have the assignment like in your first
version.
--
Armin



你好Jacky,


重载公共共享函数Concat(String,String)As String


作为共享函数意味着它属于类并且

可用作为

tmpStr = String.Concat(tmpStr,tmpStr2)

实例可以访问自己的方法和所有Class方法。因此:

tmpStr = tmpStr.Concat(tmpStr,tmpStr2)


使用String实例访问Concat很方便但是,正如你所知/>
注意到,误导,因为该对象本身并没有行动,而是作为该类别的代表。


问候,

Fergus
Hi Jacky,

Overloads Public Shared Function Concat (String, String) As String

Being a Shared Function means that it belongs to the Class and is
available as
tmpStr = String.Concat (tmpStr, tmpStr2)

Instances can access their own methods and all the Class methods. Hence:
tmpStr = tmpStr.Concat (tmpStr, tmpStr2)

Accessing Concat using an instance of String is handy but, as you''ve
noticed, misleading, because the object is not acting in its own right but as
a representative of the Class.

Regards,
Fergus


Concat方法是共享的,这意味着它无法访问实例

类的数据它包含在内。这是合乎逻辑的情况

因为字符串是不可变的(看看MSDN)。基本上,数据

不能改变,所以当你做改变时数据,实例是
销毁并创建了一个新实例。


-

HTH,

- Tom Spink,überGeek


请回复新闻组,

所以所有人都可以受益


混乱,恐慌,无序,我的工作在这里完成了

Jacky < JA ****** @ hotmail.com>在消息中写道

新闻:Op ************** @ TK2MSFTNGP10.phx.gbl ...







:Concat恶化为

:tmpStr = tmpStr.Concat(tmpStr,tmpStr2)



:为什么它不引用所有者对象所以



:tmpStr.Concat(tmpStr,tmpStr2)



:现在tmpStr与鞋面值相同?



:问候,jacky




Hi, the Concat method is shared, which means it cannot access the instance
data of the class it is contained within. It''s logical that this is the case
because strings are immutable (take a look at MSDN). Basically, the data
cannot be changed, so when you do "change" the data, the instance is
destroyed and a new instance is created.

--
HTH,
-- Tom Spink, über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"
"Jacky" <ja******@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP10.phx.gbl...
:
: Hi,
:
: Concat wors as
: tmpStr = tmpStr.Concat(tmpStr, tmpStr2)
:
: Why it do not refer to owner object so
:
: tmpStr.Concat(tmpStr, tmpStr2)
:
: and now tmpStr has same value as upper?
:
: Regards, jacky
:
:


这篇关于vb.net中的String.concat方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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