簡體   English   中英

如何使用 C# 中的 ValueType 參數調用 C++/Cli function

[英]How to call C++/Cli function with ValueType argument from C#

我正在嘗試從 C# 調用 C++ function。

這是 C++ function 定義,

StartRecording(DateTime^% startTimestamp, String^ recPath)

我想從 C# 調用它。 C# 中的定義顯示,

StartRecording(ref ValueType startTimestamp, string recPath);

我怎么能稱之為 function。 打電話一樣,

DateTime now = DateTime.Now;
StartRecording(ref now, "Path to file");

沒有編譯,錯誤是,

Error   CS1503  Argument 1: cannot convert from 'ref System.DateTime' to 'ref System.ValueType'

我最終調用 function 如下,

ValueType now = DateTime.Now;
StartRecording(ref now, "Path to file");

將 DateTime object 分配給 ValueType 解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM