gpt4 book ai didi

c# - 在 C# 中使用 的泛型方法声明

转载 作者:太空宇宙 更新时间:2023-11-03 19:39:35 25 4
gpt4 key购买 nike

<分区>

我是C#的初学者,只是一个关于泛型方法的问题。例如:

public static IQueryable<TResult> Where<TSource>(...)

所以我们只调用这个 LINQ 方法:

 var test = _context.Recipes.Where(r => !r.IsDeleted)

代替

 var test = _context.Recipes.Where<Recipe>(r => !r.IsDeleted)

那么为什么我们不直接将泛型方法声明为

public static IQueryable<TResult> Where(...)

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com