aar0n
Member
Hi,
I'm studying for the MCTS exam 70-536 and have come across the following question:
Given the following Visual Basic code sample, which interface must the custom class MyClass implement?
Dim a As MyClass, b As Boolean
a = 42
' Convert using ToBoolean.
b = Convert.ToBoolean(a)
Console.WriteLine("a = {0}, b = {1}", a.ToString, b.ToString)
Before even looking at the possible answers, I can't get past WHY on earth would we be converting the number 42 to a Boolean value??
I tried this and as I suspected it did NOT compile! Is this a trick question or am I missing something? Thanks!!!!
** edit **
I realized that in order for the code to work, I would need to implement one of the interfaces shown in the multiple choices. STILL, would there EVER be a purpose for this particular conversion?
I'm studying for the MCTS exam 70-536 and have come across the following question:
Given the following Visual Basic code sample, which interface must the custom class MyClass implement?
Dim a As MyClass, b As Boolean
a = 42
' Convert using ToBoolean.
b = Convert.ToBoolean(a)
Console.WriteLine("a = {0}, b = {1}", a.ToString, b.ToString)
Before even looking at the possible answers, I can't get past WHY on earth would we be converting the number 42 to a Boolean value??
** edit **
I realized that in order for the code to work, I would need to implement one of the interfaces shown in the multiple choices. STILL, would there EVER be a purpose for this particular conversion?
Last edited: