fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. class ReturnValueAttribute : Attribute
  5. {
  6. public object val { get; set; }
  7. public ReturnValueAttribute(object v) {val = v; }
  8. }
  9.  
  10. public class Test
  11. {
  12. public static void Main()
  13. {
  14. // your code goes here
  15. int i = foo();
  16. Console.WriteLine(i);
  17. }
  18.  
  19. [ReturnValue(100)]
  20. public static int foo()
  21. {
  22. var rtn = typeof(Test).GetMethod("foo")
  23. .GetCustomAttributes(typeof(ReturnValueAttribute), false).FirstOrDefault();
  24. return (int)((ReturnValueAttribute)rtn).val;
  25. }
  26. }
Success #stdin #stdout 0.02s 15424KB
stdin
Standard input is empty
stdout
100