gpt4 book ai didi

c# - 帮助修复 C# "A ref or out argument must be an assignable"中的错误

转载 作者:行者123 更新时间:2023-12-02 11:09:35 25 4
gpt4 key购买 nike

这是我遇到错误的代码块:

    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);
}
}

错误信息是:

A ref or out argument must be an assignable

最佳答案

关于您的第一个错误,您需要将 FlashWindow 作为变量引入,例如

这:

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# - 帮助修复 C# "A ref or out argument must be an assignable"中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7307705/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com