GetStringBytes() public static méthode

Reads the bytes representing a string from the given pointer.
public static GetStringBytes ( IntPtr pNativeData, Encoding p_encEncoding ) : List
pNativeData System.IntPtr The pointer to the string whose bytes are to be read.
p_encEncoding System.Text.Encoding The encoding of the string whose bytes are to be read.
Résultat List
Exemple #1
0
        /// <summary>
        /// Marshals the given pointer to a string.
        /// </summary>
        /// <param name="pNativeData">The pointer to the data to marshal to a string.</param>
        /// <param name="p_intSize">The length of the array to marshal.</param>
        /// <returns>The marshaled string.</returns>
        public string[] MarshalNativeToManaged(IntPtr pNativeData, Int32 p_intSize)
        {
            if (pNativeData == IntPtr.Zero)
            {
                return(null);
            }

            string[] strStrings = new string[p_intSize];
            for (Int32 i = 0; i < p_intSize; i++)
            {
                IntPtr      ptrString = Marshal.ReadIntPtr(pNativeData, i * IntPtr.Size);
                List <byte> lstString = StringMarshaler.GetStringBytes(ptrString, m_encEncoding);
                strStrings[i] = m_encEncoding.GetString(lstString.ToArray(), 0, lstString.Count);
            }
            return(strStrings);
        }