fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. private static bool TryParseOf<TType>(string s, out TType result)
  6. {
  7. if (typeof(TType) == typeof(int))
  8. {
  9. var parseSuccessful = int.TryParse(s, out int innerResult);
  10. result = (TType)(object)innerResult;
  11. return parseSuccessful;
  12. }
  13.  
  14. throw new NotImplementedException();
  15. }
  16.  
  17. public static void Main()
  18. {
  19. Console.WriteLine("{0}: {1}", TryParseOf1<int>("123", out var x), x);
  20. }
  21. }
Compilation error #stdin compilation error #stdout 0.02s 16180KB
stdin
Standard input is empty
compilation info
prog.cs(19,35): error CS0103: The name `TryParseOf1' does not exist in the current context
prog.cs(19,71): error CS8048: Cannot use uninitialized variable `x'
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty