Question
static void Main(string[] args)
{
string teststring = "MIKA@?&";
string hex = ConvertstringToHex(teststring, system.Text.Encoding.Unicode);
Console.WriteLine(hex);
}
a)
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();
}
b)
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();
}
c)
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();
}
}
a.
a
b.
b
c.
c
d.
None of the mentioned
Posted under C# programming
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. Select the appropriate set of code for conversion of string to hexa form.
Similar Questions
Discover Related MCQs
Q. Correct statement about strings are ?
View solution
Q. Verbatim string literal is better used for ?
View solution
Q. Why strings are of reference type in C#.NET ?
View solution
Q. Storage location used by computer memory to store data for usage by an application is ?
View solution
Q. DIFFERENCE BETWEEN KEYWORDS ‘VAR’ AND ‘DYNAMIC’ ?
View solution
Q. Are the given codes :
1. Myclass class;
Myclass class2 = null;
2. int i;
int j = 0;
View solution
Q. Scope of variable is related to definition of variable as:
a. Region of code within which variable value is valid and hence can be accessed.
b. No, relation with region where variable is declared its value is valid in entire scope.
View solution
Q. Syntax for declaration and initialization of data variable is :
View solution
Q. Choose effective differences between ‘Boxing’ and ‘Unboxing’.
View solution
Q. Select differences between reference type and value type :
1. Memory allocated to ‘Value type’ is from heap and reference type is from ‘System. ValueType’
2. Memory allocated to ‘Value type’ is from ‘System. ValueType’ and reference type is from ‘Heap’
3. Structures, enumerated types derived from ‘System. ValueType’ are created on stack, hence known as ValueType and all ‘classes’ are reference type because values are stored on heap
View solution
Q. What is the need for ‘Conversion of data type’ in C#?
View solution
Q. Types of ‘Data Conversion’ in C#?
View solution
Q. Implicit Conversion' follows the order of conversion as per compatibility of datatype as :
View solution
Q. Subset of ‘int’ datatype is :
View solution
Q. Type of Conversion in which compiler is unable to convert the datatype implicitly is ?
View solution
Q. Disadvantages of Explicit Conversion are ?
View solution
Q. Correct order of priorities are :
View solution
Q. The correct way of incrementing the operators are :
View solution
Q. Which of the following is/are not Relational operators in C#.NET ?
View solution
Q. Select the relevant output for the set of code :
m = 5;
int y;
1. y = m++;
2. y = ++m;
View solution
Suggested Topics
Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!