I did an online assessment and I'm trying to understand the results, and here one of the questions I did already:
Change to method declaration
So the question is this:


and the report says:

I can't see why my answer is marked as partially right, am I missing something? Also the question says this is a string manipulation question, although to me it has nothing to do with that subject.
Marco
UPDATE
Answer C is not right, I was mistaken by the fact that I used the var keyword and not the actual enum.
You've ticked two options. The one you've shown the mouse pointer at is fine, but the other one isn't.
Try it so you can see why. Note that as of .NET 4, there's Enum.TryParse<TEnum> which is generic, and thus less annoying in a few ways. Unfortunately, TryParse isn't constrained to force TEnum to be an enum type... which it couldn't be if it were declared in C#, but could be in IL. See my Unconstrained Melody project for an alternative approach here, if you're interested. (If you just want to know why you only got partial credit, I completely understand...)
(And I agree it's not really "string manipulation" as such.)
Question asks which one will return an enum. In that case fourth option is right. Third option will return an object(albeit your enum will be encapsulated in an object).
The trick here is var. All are assigned to var. So even if it returns an object or an enum all are accepted in var.
Here is proof.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With