adplus-dvertising
frame-decoration

Question

Output for the following set of code is ?
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)); 
 }

a.

Monday ,Tuesday ,Wednesday ,Friday ,Saturday ,Sunday

b.

Monday
Tuesday
Wednesday
Friday
Sunday

c.

Monday
Tuesday
Wednesday
Friday
Saturday

d.

Monday ,Tuesday ,Wednesday ,Friday ,Saturday

Posted under C# programming

Answer: (c).Monday
Tuesday
Wednesday
Friday
Saturday

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Output for the following set of code is ?

Similar Questions

Discover Related MCQs

Q. Select the correct differences between char and varchar datatypes?

1. varchar is non unicode and char is unicode character datatype
2. char is ‘n’ bytes whereas varchar is actual length in bytes of data entered in terms of storage size
3. varchar is variable in length and char is the fixed length string
4. For varchar, if a string is less than the maximum length then it is stored in verbatim without any extra characters while for char if a string is less than the set length it is padded with extra characters to equalize its length to given length

Q. Which is the String method used to compare two strings with each other ?

Q. For two strings s1 and s2 to be equal, which is the correct way to find if the contents of two strings are equal ?

Q. Correct statement about strings are ?

Q. Verbatim string literal is better used for ?

Q. Why strings are of reference type in C#.NET ?

Q. Storage location used by computer memory to store data for usage by an application is ?

Q. DIFFERENCE BETWEEN KEYWORDS ‘VAR’ AND ‘DYNAMIC’ ?

Q. Are the given codes :

1. Myclass class;
Myclass class2 = null;
2. int i;
int j = 0;

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.

Q. Syntax for declaration and initialization of data variable is :

Q. Choose effective differences between ‘Boxing’ and ‘Unboxing’.

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

Q. What is the need for ‘Conversion of data type’ in C#?

Q. Types of ‘Data Conversion’ in C#?

Q. Implicit Conversion' follows the order of conversion as per compatibility of datatype as :

Q. Subset of ‘int’ datatype is :

Q. Type of Conversion in which compiler is unable to convert the datatype implicitly is ?

Q. Disadvantages of Explicit Conversion are ?

Q. Correct order of priorities are :