帮助修复C#中的错误“引用或失败参数必须是可赋值的”

以下是我遇到错误的一段代码:

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

错误消息是:

裁判或失败论据必须是可转让的

关于你的第一个错误,你需要将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; } 

你需要一个可分配的变量参考或出参数。

 FLASHWINFO fwi = Create_FLASHWINFO(form.Handle, 15, uint.MaxValue, 0); FlashWindowEx(ref fwi);