gpt4 book ai didi

c# - param 在 c# 中意味着什么(不是 params)

转载 作者:行者123 更新时间:2023-12-04 03:47:00 29 4
gpt4 key购买 nike

我发现了以下属性声明。

     [param: MarshalAs(UnmanagedType.LPTStr)]

param 关键字在这种情况下意味着什么以及为什么我们应该使用它?

最佳答案

param属性目标。引用自MSDN :

The list of possible target values is shown in the following table.

 C#            Visual Basic    Applies to
   
assembly Assembly Entire assembly module Module Current assembly module (which is different from a Visual Basic Module) field Not supported Field in a class or a struct event Not supported Event method Not supported Method or get and set property accessors param Not supported Method parameters or set property accessor parameters property Not supported Property return Not supported Return value of a method, property indexer, or get property accessor type Not supported Struct, class, interface, enum, or delegate

在您的示例中,该属性可能用于属性 setter ,并将该属性分配给(隐式)value 参数。

关于c# - param 在 c# 中意味着什么(不是 params),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34526613/

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