欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

3rd-Hyperion-Extensions-StringEx.cs

程序员文章站 2022-03-27 12:31:33
...

using System.Runtime.CompilerServices;

namespace Hyperion.Extensions
{
    internal static class StringEx
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        internal static byte[] ToUtf8Bytes(this string str)
        {
            return NoAllocBitConverter.Utf8.GetBytes(str);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        internal static string FromUtf8Bytes(byte[] bytes,int offset, int count)
        {
            return NoAllocBitConverter.Utf8.GetString(bytes,offset,count);
        }
    }
}