Exemplo n.º 1
0
    //根据id值,返回特定字段的值,需给返回默认值
    public T GetValueFromID <T>(int id, string valName, T defVal)
    {
        CSVRow tmpRoleID = GetRowFromID(id);
        T      outVal    = defVal;

        if (tmpRoleID != null)
        {
            outVal = tmpRoleID.GetVal <T>(valName, defVal);
        }

        return(outVal);
    }
Exemplo n.º 2
0
    //根据key字段及key字段的值,返回val字段的值,需给val默认值,
    //key只支持整型,string,浮点型
    public T GetKeyValueFromID <K, T>(string keyName, K keyVal, string valName, T defVal)
    {
        T res = defVal;

        for (int i = 0; i < m_elements.Count; ++i)
        {
            K keyDefVal = (K)Convert.ChangeType("0", typeof(K));
            K tmpKey    = m_elements[i].GetVal <K>(keyName, keyDefVal);
            if (tmpKey.Equals(keyVal))
            {
                CSVRow tmpRow = m_elements[i];
                res = tmpRow.GetVal(valName, defVal);
                break;
            }
        }
        return(res);
    }