本文介绍了使用内插vs"+"来连接字符串的内存使用情况.操作员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就可读性而言,我看到了使用插值字符串的好处:

I see the benefit of using interpolated strings, in terms of readability:

string myString = $"Hello { person.FirstName } { person.LastName }!"

以这种方式进行的串联:

over a concatenation done this way:

string myString = "Hello " + person.FirstName + " " person.LastName + "!";

此视频教程的作者的作者声称,第一个视频可以更好地利用内存.

The author of this video tutorial claims that the first one makes better use of memory.

怎么来?

推荐答案

作者实际上并没有说一个比另一个能更好地利用内存.它说一种方法抽象地很好地利用了内存",它本身并没有多大意义.

The author doesn't actually say that one makes better use of memory than the other. It says that the one method "makes good use of memory" in the abstract, which, by itself, doesn't really mean much of anything.

但是,不管他们说什么,这两种方法的实现都不会有实质性的不同.就内存或时间而言,两者都不会在意义上与众不同.

But regardless of what they said, the two methods aren't going to be meaningfully different in their implementation. Neither is going to be meaningfully different from the other in terms of memory or time.

这篇关于使用内插vs"+"来连接字符串的内存使用情况.操作员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 04:55