ReSharper的着色变量在红

问题描述:

好了 - 我觉得自己很蠢,但如果我一个变量的类型ReSharper的凸显变量红色,然后提出分割声明和赋值现在ReSharper的着色变量在红

我想这个建议,但我不希望变量是红色的

有什么办法消除这种

我已经通过所有的选项看了看,还不能算出这个

public static void Add<S, D>(List<S> source, List<D> destination) 
where D : class 
{ 
    foreach (S sourceElement in source) 
    { 
     destination.Add(sourceElement); 
    } 
} 

编辑:我的问题似乎是完全一样的东西Resharper Suggestion Color Issue - 我无法下载SP2 VS 2005

基本上一些变量具有红色背景

有没有我可以使用任何其他选择吗?

+0

请出示代码样本。 – 2009-12-02 11:05:38

+0

公共静态无效添加(列表源,列表目的地)其中d:类 { 的foreach(S sourceElement在源) { destination.Add(sourceElement); } } – 2009-12-02 11:10:32

您应该能够在菜单 - > resharper - >选项 - >代码检查 - >检查严重性中设置严重性。

+0

是多数民众赞成正确 - 然而,一个建议使变量的背景全红,这是推动我坚果! – 2009-12-02 11:18:15

+0

请参阅我上面的编辑 – 2009-12-02 11:52:01

没有,错误来自你尝试分配d至S,而且也没有转换成为可能

添加另一个约束和解决错误的事实:

public static void Add<S, D>(List<S> source, List<D> destination) 
     where D : class 
     where S : D /*Solve the assignment issue */ 
    { 
     foreach (S sourceElement in source) { destination.Add(sourceElement); } 
    }