小编Jun*_*nZe的帖子

如何切换表/网格中行的颜色?

有没有办法在CSS或CSS3中切换表/网格中行的颜色?

<table>
    <thead>
        <tr>
            <td>Name</td>
            <td>Votes</td>
        </tr>
    </thead>
    <tbody class="rows">
        <tr>
            <td>Barack Obama</td>
            <td>50%</td>
        </tr>
        <tr>
            <td>Mitt Romney</td>
            <td>48%</td>
        </tr>
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

例如,奇数行是白色,偶数行是蓝色.

.rows tr:odd
{
    background-color: White
}
.rows tr:even
{
    background-color: blue
}

或者那是不可能的?

css css3

1
推荐指数
1
解决办法
550
查看次数

该对象是一个Array或IEnumerable

我想知道是否有办法找到对象是数组还是IEnumerable,它比这更漂亮:

var arrayFoo = new int[] { 1, 2, 3 };

var testArray = IsArray(arrayFoo);
// return true
var testArray2 = IsIEnumerable(arrayFoo);
// return false

var listFoo = new List<int> { 1, 2, 3 };

var testList = IsArray(listFoo);
// return false
var testList2 = IsIEnumerable(listFoo);
// return true


private bool IsArray(object obj)
{
    Type arrayType = obj.GetType().GetElementType();
    return arrayType != null;
}

private bool IsIEnumerable(object obj)
{
    Type ienumerableType = obj.GetType().GetGenericArguments().FirstOrDefault();
    return ienumerableType != null;
}
Run Code Online (Sandbox Code Playgroud)

.net c# reflection

0
推荐指数
2
解决办法
697
查看次数

标签 统计

.net ×1

c# ×1

css ×1

css3 ×1

reflection ×1