ref: 更新到 C# 语言版本 13,回滚 ArgumentReplace
This commit is contained in:
1 parent
6db2c6cfa2
commit
6432370f86
8 files changed
+45
-66
No files matched your search
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MeloongCore.Extensions;
|
||||
namespace MeloongCore.Extensions;
|
||||
public static class EnumerableExtensions {
|
||||
|
||||
#region Distinct
|
||||
@@ -133,7 +127,7 @@ public static class EnumerableExtensions {
|
||||
isFirst = false;
|
||||
else
|
||||
builder.Append(split);
|
||||
if (element != null) builder.Append(element.ToString());
|
||||
if (element is not null) builder.Append(element.ToString());
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
@@ -149,7 +143,7 @@ public static class EnumerableExtensions {
|
||||
isFirst = false;
|
||||
else
|
||||
builder.Append(split);
|
||||
if (element != null) builder.Append(element.ToString());
|
||||
if (element is not null) builder.Append(element.ToString());
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
@@ -160,7 +154,7 @@ public static class EnumerableExtensions {
|
||||
/// 判断集合是否有且仅有一个元素。
|
||||
/// </summary>
|
||||
public static bool IsSingle<T>(this IEnumerable<T> source) {
|
||||
if (source == null) return false;
|
||||
if (source is null) return false;
|
||||
if (source is IList<T> list) return list.Count == 1;
|
||||
using var enumerator = source.GetEnumerator();
|
||||
if (!enumerator.MoveNext()) return false;
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace MeloongCore.Extensions;
|
||||
namespace MeloongCore.Extensions;
|
||||
public static class StringExtensions {
|
||||
|
||||
#region 区域性 / 大小写 简化
|
||||
@@ -12,7 +8,7 @@ public static class StringExtensions {
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool StartsWithF(this string value, string prefix, bool ignoreCase = false) {
|
||||
if (value == null) return false;
|
||||
if (value is null) return false;
|
||||
return value.StartsWith(prefix, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
|
||||
}
|
||||
/// <summary>
|
||||
@@ -20,7 +16,7 @@ public static class StringExtensions {
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool EndsWithF(this string value, string suffix, bool ignoreCase = false) {
|
||||
if (value == null) return false;
|
||||
if (value is null) return false;
|
||||
return value.EndsWith(suffix, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
@@ -85,7 +81,7 @@ public static class StringExtensions {
|
||||
if (splitStr.IsSingle())
|
||||
return fullStr.Split(splitStr[0]);
|
||||
else
|
||||
return fullStr.Split(new[] {splitStr}, StringSplitOptions.None);
|
||||
return fullStr.Split([splitStr], StringSplitOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user