简体   繁体   English

为什么Visual Studio会给我这种预期的错误类型

[英]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.

相关问题 为什么这种表达方式不能给我预期的结果? - Why does this expression not give me the expected result? 为什么在我构建项目时Visual Studio没有在Test Explorer中给我测试? - Why Does Visual Studio not give me a test in Test explorer when I build my project? 当我通过 Visual Studio 中的 IIS Express 在浏览器中打开 web 应用程序时,为什么会给我这个错误? - Why give me this error when I open web app in browser through IIS Express in visual studio? 为什么这个Using()给我一个错误? - Why does this Using() give me an error? 为什么这个 IQueryable 问题会给我一个错误? - Why does this IQueryable issue give me an error? 为什么这会给我错误:80040154 - Why does this give me error: 80040154 为什么此linq查询没有给我预期的结果? - Why does this linq query not give me expected result? 为什么Visual Studio告诉我数据库不存在而存在? - Why does Visual Studio tell me that a database exists when it does not? 为什么当我想通过 C# 运行 GAMS 代码时,visual studio 给我错误? - Why does visual studio gives me error when I want to run the GAMS code via C#? 为什么将 IdentityDbContext 添加到 DbContext 会给我一个错误? - Why does adding IdentityDbContext into DbContext give me an error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM