-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
437cde2
commit b93add3
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace Songhay.Extensions; | ||
|
||
/// <summary> | ||
/// Extensions of <see cref="byte"/>. | ||
/// </summary> | ||
public static class ByteExtensions | ||
{ | ||
/// <summary> | ||
/// Converts the specified <see cref="byte"/> array to a <see cref="StreamReader"/> | ||
/// with <see cref="Encoding.UTF8"/>. | ||
/// </summary> | ||
/// <param name="bytes">the bytes</param> | ||
public static StreamReader ToStreamReader(this byte[] bytes) => bytes.ToStreamReader(Encoding.UTF8); | ||
|
||
/// <summary> | ||
/// Converts the specified <see cref="byte"/> array to a <see cref="StreamReader"/>. | ||
/// </summary> | ||
/// <param name="bytes">the bytes</param> | ||
/// <param name="encoding">the encoding</param> | ||
/// <remarks> | ||
/// This member is useful in the world of ASP.NET when there is a need | ||
/// to read a <see cref="string"/> from the bytes of a <c>MultipartSection"</c>. | ||
/// </remarks> | ||
public static StreamReader ToStreamReader(this byte[] bytes, Encoding encoding) => | ||
new(new MemoryStream(bytes), encoding); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.