diff --git a/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs b/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs
index 386027d4..e8e2e28e 100644
--- a/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs
+++ b/src/extensions/BootstrapBlazor.Socket/DataConverter/HexConverter.cs
@@ -2,8 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
-using System.Text;
-
namespace BootstrapBlazor.Components.DataConverter;
///
@@ -17,8 +15,9 @@ public static class HexConverter
///
/// The byte array to convert.
///
+ ///
/// A string containing the hexadecimal representation of the byte array.
- public static string ToString(byte[]? bytes, string? separator = "-")
+ public static string ToString(byte[]? bytes, string? separator = "-", bool upper = true)
{
if (bytes == null || bytes.Length == 0)
{
@@ -30,13 +29,7 @@ public static string ToString(byte[]? bytes, string? separator = "-")
return BitConverter.ToString(bytes);
}
- var sb = new StringBuilder(bytes.Length * 3);
- foreach (var b in bytes)
- {
- sb.Append(b.ToString("X2"));
- sb.Append(separator);
- }
- return sb.ToString(0, sb.Length - 1);
+ return string.Join(separator, bytes.Select(i => upper ? i.ToString("X2") : i.ToString("x2")));
}
///
diff --git a/src/extensions/BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs b/src/extensions/BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs
index 76b1e143..bcd0fb24 100644
--- a/src/extensions/BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs
+++ b/src/extensions/BootstrapBlazor.Socket/Extensions/DataPropertyExtensions.cs
@@ -19,7 +19,7 @@ static class DataPropertyExtensions
{
var converterParameters = attribute.ConverterParameters;
var c = Activator.CreateInstance(converterType, converterParameters);
- if(c is IDataPropertyConverter v)
+ if (c is IDataPropertyConverter v)
{
converter = v;
}