简体   繁体   English

将 httprequst 作为参数传递给 function (C#)

[英]pass httprequst as a parameter to a function (C#)

How could pass a httprequest as a parameter to a function?如何将 httprequest 作为参数传递给 function? Consider this function that is provided by another dll.考虑由另一个 dll 提供的 function。

public static System.Collections.Generic.List<FIS.UAC_Security.Models.Organization> GetUserOrganizations(this Microsoft.AspNetCore.Http.HttpRequest request, [int? userId = null])

how Could use this function?如何使用这个 function?

'this' in the argument of the function indicates that its an extension method function 的参数中的“this”表示它是一种扩展方法

so you can call it on request object itself:所以你可以根据要求调用它 object 本身:

var result = request.GetUserOrganizations();

or或者

var result = request.GetUserOrganizations(123);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM