-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtime
Description
Background and motivation
string.Empty is a static readonly empty string. Since this cannot be used in attributes, I would like to suggest that we create a constant version of this.
API Proposal
namespace System
{
public sealed class String : ICloneable, IComparable, IComparable<string>, IConvertible, IEquatable<string>, System.Collections.Generic.IEnumerable<char>
{
// Current:
public static readonly string Empty = "";
// Proposal:
// Naming could also be "ConstEmpty" instead of "ConstantEmpty"
public const string ConstantEmpty = "";
}
}API Usage
[Theory]
[InlineData(string.ConstEmpty)]
// previous: [InlineData("")]
public void MyTest(input) {
Assert.True(string.IsNullOrEmpty(input));
}Alternative Designs
No response
Risks
No risks, since only a constant is applied and does not replace the static field.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtime