我找到了以下属性声明.
[param: MarshalAs(UnmanagedType.LPTStr)]
什么param关键字在这个上下文中意味着什么,我们为什么要使用它?
param
是属性目标.从MSDN引用:
可能的目标值列表如下表所示.
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
在您的示例中,该属性可能用于属性设置器,并将该属性分配给(隐式)value
参数.