File tree Expand file tree Collapse file tree
src/extensions/BootstrapBlazor.Socket/DataConverter Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33// Website: https://www.blazor.zone or https://argozhang.github.io/
44
5- using System . Text ;
6-
75namespace BootstrapBlazor . Components . DataConverter ;
86
97/// <summary>
@@ -17,8 +15,9 @@ public static class HexConverter
1715 /// </summary>
1816 /// <param name="bytes">The byte array to convert.</param>
1917 /// <param name="separator"></param>
18+ /// <param name="upper"></param>
2019 /// <returns>A string containing the hexadecimal representation of the byte array.</returns>
21- public static string ToString ( byte [ ] ? bytes , string ? separator = "-" )
20+ public static string ToString ( byte [ ] ? bytes , string ? separator = "-" , bool upper = true )
2221 {
2322 if ( bytes == null || bytes . Length == 0 )
2423 {
@@ -30,7 +29,7 @@ public static string ToString(byte[]? bytes, string? separator = "-")
3029 return BitConverter . ToString ( bytes ) ;
3130 }
3231
33- return string . Join ( separator , bytes . Select ( i => Convert . ToString ( i , 16 ) ) ) ;
32+ return string . Join ( separator , bytes . Select ( i => upper ? i . ToString ( "X2" ) : i . ToString ( "x2" ) ) ) ;
3433 }
3534
3635 /// <summary>
You can’t perform that action at this time.
0 commit comments