Thursday, 15 August 2013

Calling method on object returns parameter string - Reflection C# -


I am trying to use reflection to call a method on one object and it can also contain parameters When no criteria are specified, the code works perfectly, but returns false data on the parameters.

Here's my code:

  object temp = readerTask.GetType () GetProperty (BSuplet [0]). GetValue (Readersk, blank); If (usage permissions) {MethodInfo methodInfo = temp.GetType (). GetPrint (new four [] {'('}) [0], new [] {typef (string)}); string p = bsplit [1] .Split (new four [] {' (',') '}) [1]; value = methodInfo.Invoke (temp, new [] {p});} else {value = temp.GetType, for example, my input string  date.ToString ( "MMMM is dd, yyyy). (For example, MSMD, yyyy)") . 

The object is the temporal right date object that I want to format, but when I run through the code, the value variable in the data is MMMM dd, Yyyy

How do I get the right way to run the parameter and use it?

p is not "MMMM dd, yyyy" , but "\" MMMM dd, yyyy \ "" .

It can be easily removed from the console. WrightLine (DateTime.Now.ToString ("\" MMMM dd, yyyy \ "")); This is exactly printed "MMMM Dd, yyyy"

You can type it in the '' ' symbol:

  Should remove MethodInfo methodInfo = temp.GetType (). GetMethod (bsplit [1] .plit (new four [] {'('}) [0], new [] {typef (string)}; string p = bsp} [1] .split (new four [] {' (P, [0] = '' ') {p = p.Substring (1, p.Length - 2)}} value = methodInfo.Invoke (temp, new [ ] {P});  

No comments:

Post a Comment