String a = "sss"; and string a = new string ("sss"); Is there any difference?

xiaoxiao2021-03-06  56

String a = "sss"; and string a = new string ("sss"); Is there any difference?

Different.

The former will check that there is no "sss" in the buffer pool. If there is no new system resource generated object, it is possible to reference the same address.

Every time the latter generates new objects, it is impossible to reference the same address.

转载请注明原文地址:https://www.9cbs.com/read-114657.html

New Post(0)