Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the String.Empty fields?

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces what are the String.Empty fields, which are introduced in great detail and have certain reference value. Friends who are interested must finish reading them.

String.Empty, is an empty string.

String.Empty field

.net Framework class library

Represents an empty string. This field is read-only. Namespace: System

Assemblies: mscorlib (in mscorlib.dll)

ProtectedstringloginId=String.Empty

ProtectedstringloginId= ""

"" allocate a storage space with an empty length

So we usually use string.Empty.

In order to cross-platform in the future, use string.empty.

In C #, "" and string.Empty can be used interchangeably in most cases. For example:

Strings= ""

Strings2=string.Empty

If (s==string.Empty) {

/ /

}

If statement established

Several writing methods for determining an empty string, in order of performance from high to low, are:

S.Length==0 is better than s==string.Empty.

Your question about String.Empty and Null is that both represent empty strings, and one of the key points is the difference between stringstr1=String.Empty and stringstr2=null. After this definition, str1 is an empty string, and the empty string is a special string, but the value of this string is empty and there is an accurate point in memory, stringstr2=null. After this definition, you only define a reference to the string class. Str2 does not point anywhere and will report an error if it is not instantiated before use. The value of textBox1.Text is a zero-length string''.

String.Empty support platform

Windows98, Windows2000SP4, WindowsCE, WindowsMillenniumEdition, WindowsMobileforPocketPC, WindowsMobileforSmartphone, WindowsServer2003, WindowsXPMediaCenterEdition, WindowsXPProfessionalx64Edition, WindowsXPSP2, WindowsXPStarterEdition, WindowsVista, Windows7, Windows8 and 8.1.

The .NET Framework does not support all versions of every platform. For a list of supported versions, see system requirements.

Version information

.NETFramework

Supported by the following versions: 4.5, 4.0, 3.5, 2.0, 1.1, 1.0

.NETCompactFramework

Supported by the following versions: 2.0, 1.0

Related entries DBNull, Null, and String.Empty

The above is all the content of this article "what are the String.Empty fields?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report