[英]Why does visual studio give me this error type expected
I'm Developing windows phone 8.1 application when i want to start emulator Give me this error "Type expected" line 27 this is the line of code: 当我想启动模拟器时,我正在开发Windows Phone 8.1应用程序。给我这个错误“预期类型”第27行,这是代码行:
statusBar.BackgroundColor = new ((SolidColorBrush)Windows.UI.Xaml.Application.Current.Resources["PhoneAccentBrush"]);
` `
Error is clear, you are not telling the type name: 错误很明显,您没有告诉类型名称:
statusBar.BackgroundColor = new (...);
-------^
Now, you've got a SolidColorBrush
(after casting) but you're trying to get a Color
. 现在,您已经有了
SolidColorBrush
(在投射之后),但是您正在尝试获取Color
。 Fortunately, SolidColorBrush
has a Color
property which is what I suspect you want: 幸运的是,
SolidColorBrush
具有Color
属性,这是我怀疑您想要的:
var brush = (SolidColorBrush) Application.Current.Resources["PhoneAccentBrush"];
statusBar.BackgroundColor = brush.Color;
You're trying to use the new
operator, which requires a type, like this: 您正在尝试使用需要一个类型的
new
运算符,如下所示:
variable = new SomeType(constructorArguments);
You've got new
and then a cast. 您有
new
,然后是演员。
I suspect you just want the cast, without new
: 我怀疑你只是想要演员,没有
new
:
// With a using directive for Windows.UI.Xaml...
statusBar.BackgroundColor = (SolidColorBrush) Application.Current.Resources["PhoneAccentBrush"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.