是否可以从func<>
返回值?
喜欢这个
public interface IMusic
{
string Type { get; set; }
string Name { get; set; }
List<IMusic> Music { get; set; }
}
public class Rap : IMusic
{
public List<IMusic> Music { get; set; }
public string Name { get; set; }
public string Type { get; set; }
}
public class Mix : IMusic
{
public List<IMusic> Music { get; set; }
public string Name { get; set; }
public string Type { get; set; }
}
public class Rock : IMusic
{
public List<IMusic> Music { get; set; }
public string Name { get; set; }
public string Type { get; set; }
}
public class Program
{
static void Main()
{
var r = Music<Rock>((a => a.Name));
Console.WriteLine(r);
Console.ReadLine();
}
static object Music<T>(Func<T, object> music)
{
return music;
}
}
例如,当我在参数i
中使用func时,想要从方法
MethodName(a => a.FirstName == "Test")
=这是真的吗?