http://stackoverflow.com/questions/9647641/resharper-warns-static-field-in-generic-type

It's fine to have a static field in a generic type, so long as you know that you'll really get one field per combination of type arguments. My guess is that R# is just warning you in case you weren't aware of that.

Here's an example of that:

using System;

public class Generic<T>
{
// Of course we wouldn't normally have public fields, but...
public static int Foo;
} public class Test
{
public static void Main()
{
Generic<string>.Foo = ;
Generic<object>.Foo = ;
Console.WriteLine(Generic<string>.Foo); //
}
}

As you can see, Generic<string>.Foo is a different field from Generic<object>.Foo - they hold separate values.

ReSharper warns: “Static field in generic type”的更多相关文章

  1. java.lang.NoSuchFieldError: No static field abc_ic_ab_back_mtrl_am_alpha of type I in class Landroid/support/v7/appcompat/R$drawable

    出现java.lang.NoSuchFieldError: No static field abc_ic_ab_back_mtrl_am_alpha of type I in class Landro ...

  2. Android java.lang.NoSuchFieldError: No static field xxx of type I in class Lcom/XX/R$id; or its superclasses

    项目开发快到尾声,突然发现之前一个模块莫名其妙的奔溃了,我的内心也是奔溃的.以前一直都是好好的,也没去动过它,为啥会出现这样的问题呢? 下面我会根据自己的理解来看待问题 android是怎么根据id查 ...

  3. Android 找不到所标识的资源 java.lang.NoSuchFieldError: No static field XXX of type I in class Lcom/XX/R$id

    报错: java.lang.NoSuchFieldError: No static field XXX of type I in class Lcom/XXX/R$id; or its supercl ...

  4. java.lang.NoSuchFieldError: No static field XXX of type I in class Lcom/XX/R$id; or its superclasses

    报错: 当启动一个页面的时候报错: java.lang.NoSuchFieldError: No static field XXX of type I in class Lcom/XXX/R$id; ...

  5. Android No static field XXX of type I in class Lcom/XXX/R$id错

    问题复现: 问题原因: 出现这样的情况,你先检查你的依赖工程(module)的对应布局layout/xxx.xml是否跟主项目的layout重名,你点开R文件的时候,你会发现你的布局发生了错乱,导致你 ...

  6. java generic type

    java generic type: 类型安全.类型参数化.不需要强制转换

  7. openerp学习笔记 domain 增加扩展支持,例如支持 <field name="domain">[('type','=','get_user_ht_type()')]</field>

    示例代码1,ir_action_window.read : # -*- coding: utf-8 -*-from openerp.osv import fields,osv class res_us ...

  8. 程序编译是出现"field has incomplete type"问题的解决

    在编译程序是出现了如下错误, 类或结构体的前向声明只能用来定义指针对象或引用,因为编译到这里时还没有发现定义,不知道该类或者结构的内部成员,没有办法具体的构造一个对象,所以会报错. 将类成员改成指针就 ...

  9. eclipse中如何去除警告:Class is a raw type. References to generic type Class<T> should be parameterized

    转自:https://blog.csdn.net/zwr_1022/article/details/78583872 解决前的源代码: public class test {public static ...

随机推荐

  1. cc.Button

    cc.Button 1:添加按钮的方法 (1)直接创建带Button组件的节点; (2)先创建节点,再添加组件;2:按钮组件, 按钮是游戏中最常用的组件, 点击然后响应事件;3: 按钮的过渡效果:  ...

  2. Hihocoder #1938 最大权闭合子图模板

    这里的讲解很不错,适合作为入坑题: Hihocoder#1938 代码: #include<algorithm> #include<iostream> #include< ...

  3. [Python3网络爬虫开发实战] 1.8.3-Scrapy-Splash的安装

    Scrapy-Splash是一个Scrapy中支持JavaScript渲染的工具,本节来介绍它的安装方式. Scrapy-Splash的安装分为两部分.一个是Splash服务的安装,具体是通过Dock ...

  4. codeforces 407 div1 B题(Weird journey)

    codeforces 407 div1 B题(Weird journey) 传送门 题意: 给出一张图,n个点m条路径,一条好的路径定义为只有2条路径经过1次,m-2条路径经过2次,图中存在自环.问满 ...

  5. Spring之HelloWorld

    [Spring是什么?] 1.Spring是一个开源框架. 2.Spring为简化企业级应用开发而生,使用Spring可以使简单的JavaBean实现以前只有EJB(EJB是sun的JavaEE服务器 ...

  6. table 设置自动宽度后 td 的固定宽度 在 谷歌浏览器自动拉伸

    table   设置自动宽度后   td 的固定宽度  在 谷歌浏览器自动拉伸 解决方案 <table style="table-layout:fixed;">

  7. 洛谷P1257 平面上的最接近点对

    n<=10000个点,求欧几里德距离最小的一对点. 经典分治,把这些点按x排序,分成两半,每边分别算答案,答案是左边的最小,右边的最小,左右组起来的最小三者的最小.发现只有左右组的有点难写. 假 ...

  8. 通过setContentView设置activity的不同样式

    public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle saved ...

  9. csu - 1566: The Maze Makers (bfs)

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1566 题意还是蛮难懂的,至少对于我来说,需要认真读题. 输入矩阵的每一个数字换成2进制后,顺时针围 ...

  10. Mayor's posters POJ - 2528

    The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign h ...