public static T Process<T>(this string key)
where T:bool,string, DateTime
{
var tType = typeof(T);
if(tType == typeof(DateTime))
{
return DateTime.Parse(key.InnerProcess());
}
else if(tType == typeof(bool))
{
return bool.Parse(key.InnerProcess());
}
else if(tType == typeof(string))
{
return key.InnerProcess();
}
}
bool から T、または datetime から T に型キャストできないと書かれています。これを達成するにはどうすればよいですか?
はinnerPrecess()
私に文字列を与えます。指定されたパラメーターの型に解析してから返したいと思います。