gs gs108 Data Types, Variables and Operators - Char Types and String Literals - Quiz No.1
gs gs108 CSharp Quiz
This quiz belongs to book/course code gs gs108 CSharp of gs organization. We have 110 quizzes available related to the book/course CSharp. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Data Types, Variables and Operators. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
static void Main(string[] args) { char c = 'g'; string s = c.ToString(); string s1 = "I am a human being" + s; Console.WriteLine(s1); Console.ReadLine(); }
static void Main(string[] args) { var days = "MTWTFSS"; var daysArray = days.ToCharArray().Cast<string>().ToArray(); for (var i = 0; i < daysArray.Length; i++) { switch (daysArray[i]) { case "M": daysArray[i] = "Monday"; break; case "T": daysArray[i] = "Tuesday"; break; case "W": daysArray[i] = "Wednesday"; break; case "R": daysArray[i] = "Thursday"; break; case "F": daysArray[i] = "Friday"; break; case "S": daysArray[i] = "Saturday"; break; case "U": daysArray[i] = "Sunday"; break; } } daysArray[daysArray.Length - 1] = "and " + daysArray[daysArray.Length - 1]; Console.WriteLine(string.Join(", ", daysArray)); }
static void Main(string[] args) { { var dayCode = "MTWFS"; var daysArray = new List<string>(); var list = new Dictionary<string, string> { {"M", "Monday"}, {"T", "Tuesday"}, {"W", "Wednesday"}, {"R", "Thursday"}, {"F", "Friday"}, {"S", "Saturday"}, {"U", "Sunday"} }; for (int i = 0,max = dayCode.Length; i < max; i++) { var tmp = dayCode[i].ToString(); if (list.ContainsKey(tmp)) { daysArray.Add(list[tmp]); } } Console.WriteLine(string.Join("\n ", daysArray)); }
Monday Tuesday Wednesday Friday Sunday
Monday Tuesday Wednesday Friday Saturday
int c; c = s1.CompareTo(s2);
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(); } }