fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public class Foo {
  6. public readonly string Value;
  7.  
  8. public Foo(string value) {
  9. this.Value = value;
  10. }
  11. }
  12.  
  13. public static void Main()
  14. {
  15. var bar = "Bar";
  16. var baz = "Baz";
  17.  
  18. var ctor = typeof(Foo).GetConstructor(new[] { typeof(string) });
  19.  
  20. var foo = new Foo(bar);
  21.  
  22. Console.WriteLine(foo.Value);
  23. var obj = ctor.Invoke(foo, new[] { baz });
  24.  
  25. Console.WriteLine(foo.Value);
  26. }
  27. }
Success #stdin #stdout 0.01s 131200KB
stdin
Standard input is empty
stdout
Bar
Baz