I have tried to get the ToLower() method of string using the below code.
var tolowerMethod = typeof(string).GetMethods().Where(m => m.Name == "ToLower").FirstOrDefault();
I am trying to get the ToString() method of DateTime. I have used the below code
var formatMethod = typeof(DateTime).GetMethods().Where(m => m.Name == "ToString").ElementAt(1);
This is not unique. I have tried something like below but without success.
var formatMethod2 = typeof(DateTime).GetMethods().Where(m => m.Name == "ToString").Where(x=>x.GetParameters().Select(t=>t.ParameterType).Equals(typeof(string))).FirstOrDefault();
any Ideas?
Thanks
Does it have to be linq?
You probably want something like :
or
or
…