Skip to main content
 首页 » 编程设计

c#之尝试调用具有 out 参数的函数时出现问题

2024年02月13日16txw1958

我有这样的功能:

example(long a,long b,string c,DateTime d,DateTime e,out decimal f) 

当我尝试调用它时,我正在这样做:

long a =1; 
long b=2; 
string c=""; 
DateTime d=DateTime.Now; 
DateTime e=DateTime.Now; 
decimal f=0; 
 
example(a,b,c,d,e,f) --> Here is giving me the error : the best overloaded method has some invalid argument  

你能帮我解决这个问题吗

请您参考如下方法:

你需要调用example(a,b,c,d,e, out f);

而且f不需要初始化,最好不要初始化(误导):

//decimal f=0; 
decimal f;