You can use encoding like ASCII to get a character per byte by using the System.Text.Encoding
class.
or try this
System.Text.ASCIIEncoding.Unicode.GetByteCount(string);
System.Text.ASCIIEncoding.ASCII.GetByteCount(string);
More Related Contents:
- Byte to Binary String C# – Display all 8 digits
- Making a List in C# with three flexible elements in one datatype
- How can I convert String to Int?
- How do I get a consistent byte representation of strings in C# without manually specifying an encoding?
- .NET String.Format() to add commas in thousands place for a number
- In C#, should I use string.Empty or String.Empty or “” to intitialize a string?
- C# string replace does not actually replace the value in the string [duplicate]
- Easiest way to split a string on newlines in .NET?
- Converting string to byte array in C#
- How do I replace the *first instance* of a string in .NET?
- How do I check the number of bytes consumed by a structure?
- Best way to repeat a character in C#
- Are there any Fuzzy Search or String Similarity Functions libraries written for C#? [closed]
- Does .NET provide an easy way convert bytes to KB, MB, GB, etc.?
- Get the index of the nth occurrence of a string?
- How to compare Unicode characters that “look alike”?
- Getting hash of a list of strings regardless of order
- Memory Efficiency and Performance of String.Replace .NET Framework
- Parse C# string to DateTime
- Easier way of writing null or empty?
- How can I get a character in a string by index?
- What is the difference between .Equals and == [duplicate]
- What’s a good way of doing string templating in .NET?
- Is there a “String.Format” that can accept named input parameters instead of index placeholders? [duplicate]
- Convert binary string into integer
- DateTime conversion from string C#
- How can I Unescape and Reescape strings in .net?
- Why only literal strings saved in the intern pool by default?
- Checking for null before ToString()
- what’s the use of string.Clone()?