System.Xml.XmlConverter.ToBytes C# (CSharp) Méthode

ToBytes() static public méthode

static public ToBytes ( string value ) : byte[]
value string
Résultat byte[]
        static public byte[] ToBytes(string value)
        {
            try
            {
                return UTF8Encoding.GetBytes(value);
            }
            catch (DecoderFallbackException exception)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateEncodingException(value, exception));
            }
        }

Usage Example

Exemple #1
0
        public byte[] GetString(out int offset, out int length)
        {
            StringHandleType type = _type;

            if (type == StringHandleType.UTF8)
            {
                offset = _offset;
                length = _length;
                return(_bufferReader.Buffer);
            }
            if (type == StringHandleType.Dictionary)
            {
                byte[] buffer = _bufferReader.GetDictionaryString(_key).ToUTF8();
                offset = 0;
                length = buffer.Length;
                return(buffer);
            }
            if (type == StringHandleType.ConstString)
            {
                byte[] buffer = XmlConverter.ToBytes(s_constStrings[_key]);
                offset = 0;
                length = buffer.Length;
                return(buffer);
            }
            else
            {
                DiagnosticUtility.DebugAssert(type == StringHandleType.EscapedUTF8, "");
                byte[] buffer = XmlConverter.ToBytes(_bufferReader.GetEscapedString(_offset, _length));
                offset = 0;
                length = buffer.Length;
                return(buffer);
            }
        }
All Usage Examples Of System.Xml.XmlConverter::ToBytes