Counts how many bytes the string will use, including the null terminator. Uses UTF8 encoding. - CSharp System

CSharp examples for System:Byte

Description

Counts how many bytes the string will use, including the null terminator. Uses UTF8 encoding.

Demo Code


using System.Text;
using System.Collections.Generic;
using System;//from w w w. j  a  v a2  s . c o m

public class Main{
        /// <summary>
        /// Counts how many bytes the string will use, including the null terminator. Uses UTF8 encoding.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static int GetByteCountUtf8(string value)
        {
            return Encoding.UTF8.GetByteCount(value);
        }
}

Related Tutorials