public static string GetTreeJsonByList<T>(List<T> list, Func<T, bool> filter, string pn, string In)
{
//
}
public static string GetTreeJsonByList<T>(List<T> list, Func<T, bool> filter, string pn, string In)
{
//
}
wrote you an example of a call to .NET Core 2 for reference:
using System;
using System.Collections.Generic;
namespace GenericMethodDemo {
class Program {
static void Main (string[] args) {
var trees = new List<Tree> { };
//GetTreeJsonByList2
// 1.filternull
var result1 = GetTreeJsonByList (trees, null, "pn", "In");
Console.WriteLine ($"result 1:{result1}");
// 2.filternull
var result2 = GetTreeJsonByList (trees, x => x.Id > 100, "pn", "In");
Console.WriteLine ($"result 2:{result2}");
Console.ReadKey ();
}
public static string GetTreeJsonByList<T> (List<T> list, Func<T, bool> filter, string pn, string In) {
//
return "output";
}
}
public class Tree {
public int Id { get; set; }
public string Name { get; set; }
public int Sort { get; set; }
}
}
Note: the generic T in the above call example is: Tree
this entity object.
if you have any questions related to .NET development, you can go to a community of programming enthusiasts who focus on .NET development-Tuxing.com to find the answer. In the development of .NET, help you find more beautiful and advanced solutions to difficult problems