C# Programming - Functions and Subroutines - Discussion

Discussion :: Functions and Subroutines - General Questions (Q.No.13)

13. 

What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            object[] o = new object[] {"1", 4.0, "India", 'B'};
            fun (o);
        }
        static void fun (params object[] obj)
        {
            for (int i = 0; i < obj.Length-1; i++)
            Console.Write(obj[i] + " ");
        }
    }
}

[A]. 1 4.0 India B
[B]. 1 4.0 India
[C]. 1 4 India
[D]. 1 India B

Answer: Option C

Explanation:

No answer description available for this question.

Mot said: (Jun 8, 2011)  
Not getting ... why not float value is 4.0 ?

Ashish said: (Feb 24, 2012)  
This is correct
object o1 = 4.50;
console.Write(o1);
than output=>4.5

Min said: (Apr 6, 2012)  
@Mot.

4. 0 == 4, and it's stored as 4. There is no trailing zero when stored. And the default string output of 4 is "4".

Darshana said: (Jul 27, 2013)  
What about b?

Kiran said: (Sep 20, 2013)  
You can print b if we changes the condition in the for loop, as
i <= obj.Length - 1. Will print you b.

Sotheanat said: (Aug 8, 2019)  
What about letter 'B'?

It is not printed out why?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.