为什么 visual studio 给我预期的错误类型

Why does visual studio give me this error type expected

我正在开发 windows phone 8.1 应用程序,当我想启动模拟器时给我这个错误 "Type expected" 第 27 行这是代码行:

statusBar.BackgroundColor = new ((SolidColorBrush)Windows.UI.Xaml.Application.Current.Resources["PhoneAccentBrush"]);

`

您正在尝试使用 new 运算符,它需要一个类型,如下所示:

variable = new SomeType(constructorArguments);

你有 new 然后是演员表。

怀疑你只是想要演员表,没有new:

// With a using directive for Windows.UI.Xaml...
statusBar.BackgroundColor = (SolidColorBrush) Application.Current.Resources["PhoneAccentBrush"];

错误很明显,你没有告诉类型名称:

statusBar.BackgroundColor = new (...);
                         -------^

现在,你得到了一个 SolidColorBrush (after casting) but you're trying to get a Color. Fortunately, SolidColorBrush has a Color 属性,这就是我怀疑你想要的:

var brush = (SolidColorBrush) Application.Current.Resources["PhoneAccentBrush"];
statusBar.BackgroundColor = brush.Color;