-1

I gonna get MethodInfo of String.TrimStart()
The following code returns null.

typeof(string).GetMethod("TrimStart", new Type[ ] {});

and the following code returns {System.String TrimStart(Char[])}

typeof(string).GetMethod("TrimStart", BindingFlags.Public | BindingFlags.Instance);

I wanna get {System.String TrimStart()} exactly ?

Mohammad Dayyan
  • 21,578
  • 41
  • 164
  • 232

1 Answers1

3

There is no String.TrimStart() method.

There is only String.TrimStart(params Char[] source) overload. You can invoke it without any paramteres thanks to params keyword.

In other words: String.TrimStart() "invokes" String.TrimStart(new char[0]).

More: params keyword on msdn

Marc Selis
  • 833
  • 12
  • 17
  • Could you please post ot link to how call `TrimStart` with expression? – Mohammad Dayyan Dec 17 '14 at 07:57
  • 2
    Here is link: http://msdn.microsoft.com/en-us/library/dd323922(v=vs.110).aspx First arg is `MethodInfo`. Collection of `Expression` in the second argument should hold one item - expression, that after compile returns `char[]`. It could be `Expression.Constant(new char[0])`. –  Dec 17 '14 at 08:08