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.
Background and motivation
string.Emptyis astatic readonlyempty string. Since this cannot be used in attributes, I would like to suggest that we create a constant version of this.API Proposal
API Usage
Alternative Designs
No response
Risks
No risks, since only a constant is applied and does not replace the static field.