Send an unknown method call: Difference between revisions

Content added Content deleted
m (Added Sidef language)
(Add C sharp)
Line 92: Line 92:
{{out}}
{{out}}
<pre>3</pre>
<pre>3</pre>

=={{header|C sharp|C#}}==
<lang csharp>using System;

class Example
{
public int foo(int x)
{
return 42 + x;
}
}

class Program
{
static void Main(string[] args)
{
var example = new Example();
var method = "foo";
var result = (int)example.GetType().GetMethod(method).Invoke(example, new object[]{ 5 });
Console.WriteLine("{0}(5) = {1}", method, result);
}
}
</lang>
{{out}}
foo(5) = 47


=={{header|E}}==
=={{header|E}}==