帮助修复 C# 中的错误“引用或输出参数必须是可赋值的"; [英] Help fixing errors in C# "A ref or out argument must be an assignable"
本文介绍了帮助修复 C# 中的错误“引用或输出参数必须是可赋值的";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我遇到错误的一段代码:
Here's a block of code I'm having errors with:
public static bool Flash(Form form)
{
return (Win2000OrLater && FlashWindowEx(ref Create_FLASHWINFO(form.Handle, 15, uint.MaxValue, 0))); //A ref or out argument must be an assignable variable
}
public static bool Flash(Form form, uint count)
{
return (Win2000OrLater && FlashWindowEx(ref Create_FLASHWINFO(form.Handle, 3, count, 0))); //A ref or out argument must be an assignable variable
}
private static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
public static bool Start(Form form)
{
return (Win2000OrLater && FlashWindowEx(ref Create_FLASHWINFO(form.Handle, 3, uint.MaxValue, 0))); //A ref or out argument must be an assignable variable
}
public static bool Stop(Form form)
{
return (Win2000OrLater && FlashWindowEx(ref Create_FLASHWINFO(form.Handle, 0, uint.MaxValue, 0))); //A ref or out argument must be an assignable variable
}
private static bool Win2000OrLater
{
get
{
return (Environment.OSVersion.Version.Major >= 5);
}
}
错误信息是:
ref 或 out 参数必须是可赋值的
A ref or out argument must be an assignable
推荐答案
关于你的第一个错误,你需要将 FlashWindow 作为变量引入,例如
Regarding your first errors, you need to introduct the FlashWindow as a variable so for example
这个:
public static bool Flash(Form form)
{
return (Win2000OrLater && FlashWindowEx(ref Create_FLASHWINFO(form.Handle, 15, uint.MaxValue, 0))); //A ref or out argument must be an assignable variable
}
变成:
public static bool Flash(Form form)
{
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(form.Handle, 15, uint.MaxValue, 0);
return (FlashWindowEx(ref fi));
}
return false;
}
这篇关于帮助修复 C# 中的错误“引用或输出参数必须是可赋值的";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文