Friday .NET Trivia 1
Stumbled across an interesting piece of code yesterday. Considering what we know about .NET reference and value types two questions regarding the snippet below :
- Would the snippet below compile?
- If it compiles how would it work and what would the result be?
Venture a guess before compiling :-)
1: using System;
2: using System.Collections.Generic;
3: using System.Text;
4:
5: namespace Adp.Snippets
6: { 7: class Program
8: { 9: static Type Foo(Enum x)
10: { 11: return x.GetType();
12: }
13:
14: static void Main(string[] args)
15: { 16: DayOfWeek dow = DayOfWeek.Monday;
17: Type t = Foo(dow);
18:
19: Console.WriteLine(t);
20: }
21: }
22: }