ふらっとVisual C#,C♯,C#(初心者用) Part108
■ このスレッドは過去ログ倉庫に格納されています
0622デフォルトの名無しさん
2013/11/21(木) 22:16:22.98�@
public static string GetName<T>(T source) {
return cache.GetOrAdd(typeof(T), t => t.GetProperties()[0].Name);
}
private static ConcurrentDictionary<Type, string> cache = new ConcurrentDictionary<Type, string>();
�A
public static string GetName<T>(T source) {
return Cache<T>.Name;
}
private static class Cache<T> {
static Cache {
Name = typeof(T).GetProperties()[0].Name;
}
public static readonly string Name;
}
■ このスレッドは過去ログ倉庫に格納されています