Obtaining method signature
C#
1
Posts
1
Posters
0
Views
1
Watching
-
How to get syntactically correct signature which compiles for code template grneration ? I tried code below but it creates syntactically incorrect signature.
using System;
using System.Collections.Generic;public class MainClass
{
static string GetSignature(Type xTheType, string method)
{
var xModule = xTheType.Module;
var xTheMethod = xTheType.GetMethod(method);
return xTheMethod.ToString();
}public static void Main() { // Observed: Void Test(System.Object, System.Collections.Generic.List\`1\[System.String\]) // Expected: public void Test(object p1, List<string> p2) // or some other syntactically correct signature Console.WriteLine(GetSignature(typeof(MainClass), "Test")); } public void Test(object p1, List<string> p2) { }
}
Andrus