【问题标题】:Visual Studio 2012 complains about comparing two BrushesVisual Studio 2012 抱怨比较两个画笔
【发布时间】:2014-03-23 04:56:14
【问题描述】:

Visual Studio 2012 抱怨比较两个画笔:

private void SetLabel(string stText, Brushes colorBackground)
{
  if (colorBackGround == Brushes.Yellow)
 ...
}

错误信息:"The name 'colorBackGround' does not exist in the current context"

【问题讨论】:

  • 您没有声明 colorBackGround 或没有正确包含文件/单元
  • Visual Studio 2012 complains - 您的代码错误。这不是 IDE S 的错:
  • 抱歉 colorBackground 错字 -> 我已经修复它但没有正确复制它 -> 混合过多。正确的错误消息是“运算符'=='不能应用于'System.Windows.Media.Brushes'和'System.Windows.Media.SolidColorBrush'类型的操作数”我尝试将Brushes colorBackground更改为SolidColorBrush colorBackground - >它是对“if”语句感到满意,但不喜欢 gLBl.Background = colorBackGround -> 假设将其更改为 SolidColorBrush 是一个错误。

标签: visual-studio-2012 brushes


【解决方案1】:

colorBackGround 和 colorBackground 不一样! C# 区分大小写

【讨论】:

    猜你喜欢
    • 2017-12-13
    • 2013-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-31
    相关资源
    最近更新 更多