본문 바로가기
Programming

public T GetData(string a_strKey)

by PLUSLUTE 2022. 2. 22.

public T GetData(string a_strKey)
        {
            string _strValue;
            data.TryGetValue(a_strKey, out _strValue);

            object _value = null;
            if (typeof(T) == typeof(int)) { _value = int.Parse(_strValue); }
            if (typeof(T) == typeof(float)) { _value = float.Parse(_strValue); }
            if (typeof(T) == typeof(string)) { _value = _strValue; }
            return (T)_value;
        }