简体   繁体   English

C指针结构-缓冲区指向另一个结构。 如何在C#中?

[英]C pointer structure - buffer points to another structure. How to in C#?

This was given to me in C: 这是用C给我的:

CDCAInput := PTCDCAInput(@CDCAr);

I was only told: The pointer of the structure TCDCAInput is used by functions to pass additional input fields required for transactions. 仅告诉我:函数TCDCAInput结构的指针用于传递事务所需的其他输入字段。 Buffer to which it points will be filled in response with the CDCAResult structure. 它指向的缓冲区将用CDCAResult结构填充。

I think the @CDCAr is an instance of the CDCAResult structure. 我认为@CDCAr是CDCAResult结构的实例。 But not entirely sure about the meaning of the entire line of code. 但是,不能完全确定整个代码行的含义。

For someone like me who doesn't know C ... I cannot figure how to write its equivalent in C#. 对于像我这样不了解C的人……我无法弄清楚如何用C#编写等效的代码。

Any assistance is greatly appreciated. 非常感谢您的协助。 thanks 谢谢

I don't know C# so I can't fully answer the question, but can explain some things that may help... 我不了解C#,所以我无法完全回答问题,但是可以解释一些可能有所帮助的事情...

It's a common convention in Pascal and Delphi to name structured types (Records and Classes) starting with "T". 在Pascal和Delphi中,以“ T”开头的结构化类型(记录和类)是一个常见约定。 Another convention is to name pointer types starting with "P". 另一个约定是命名以“ P”开头的指针类型。

With those conventions, there is probably a Record (like a C struct) type named TCDCAInput , and also a type named PTCDCAInput declared as a pointer to a TCDCAInput . 这些公约,有可能是一个记录(如C结构)型名为TCDCAInput ,并命名类型PTCDCAInput声明为一个指向TCDCAInput

@ is Pascal's "address of" operator, which gives the address of a variable. @是Pascal的“地址”运算符,它给出变量的地址。

Pascal type-casts have a syntax like this: TypeName(VariableName) Pascal类型转换具有如下语法: TypeName(VariableName)

So overall, the line: 总的来说,这一行:

CDCAInput := PTCDCAInput(@CDCAr);

Means: cast the address of the CDCAr variable to the PTCDCAInput type, and assign that value to the CDCAInput variable. 含义:将CDCAr变量的地址转换为PTCDCAInput类型,然后将该值分配给CDCAInput变量。

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

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