我是C#的新手,但根据我的理解,这段代码应该可行.为什么不起作用?
这是我的代码的一个例子.
List<Car> cars // This has many cars initialized in it already
if (() => {
foreach(Car car in cars){
if (car.door == null) return true;
}
}){then .......}
Run Code Online (Sandbox Code Playgroud)
简单地说,if如果任何汽车没有门,我想要的代码就是运行语句.
尝试编译后,我收到此错误:
无法将lambda表达式转换为类型'bool',因为它不是委托类型.
目前,我正在使用此代码将 RGB 字符串转换为颜色,以设置为文本框的背景。
ColorConverter colorConverter = new ColorConverter();
colorTextBox1.BackColor = (Color)colorConverter.ConvertFromString(displayColor);
Run Code Online (Sandbox Code Playgroud)
但是当我运行此代码时出现此错误。当 的值为displayColor = "#16776960".
An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll
Additional information: Control does not support transparent background colors.
Run Code Online (Sandbox Code Playgroud)
关于如何从颜色中去除透明度有什么想法吗?
我想要它做的就是使文本框的背景变成这种颜色。