Select The Appropriate Set Of C Code For Conversion Of String #35
Select the appropriate set of C# code for conversion of string to hexa form.</p> <pre><code class="language-csharp" line="1"> static void Main(string[] args) { string teststring = "MIKA@?&"; string hex = ConvertstringToHex(teststring, system.Text.Encoding.Unicode); Console.WriteLine(hex); } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs108 CSharp. It can also be found in gs gs108 Data Types, Variables and Operators - Char Types and String Literals - Quiz No.1.
Select the appropriate set of C# code for conversion of string to hexa form.
static void Main(string[] args) { string teststring = "MIKA@?&"; string hex = ConvertstringToHex(teststring, system.Text.Encoding.Unicode); Console.WriteLine(hex); }
static string ConvertstringToHex(string input, system.Text.Encoding encoding) { string Bytes = encoding.GetBytes(input); string Builder sbBytes = new Builder sbBytes(); for each (byte 'b' in StringBytes) { sBytes.AppendFormat("{0:x2}", b); } return sbBytes.Tostring(); }
static string ConvertstringToHex(string input, system.Text.Encoding encoding) { char[]string Bytes = encoding.GetBytes(input); string Builder sbBytes = new Builder sbBytes(StringBytes.Length*2); for each (byte 'b' in StringBytes) { sBytes.AppendFormat("{0:X2}", b); } return sbBytes.Tostring(); }
public static string ConvertStringToHex(String input, System.Text.Encoding encoding) { { Byte[] stringBytes = encoding.GetBytes(input); StringBuilder sbBytes = new StringBuilder(stringBytes.Length * 2); foreach (byte b in stringBytes) { sbBytes.AppendFormat("{0:X2}", b); } Console.WriteLine(sbBytes.ToString());//sbBytes.ToString()); return sbBytes.ToString(); } }
None of the mentioned