- 877 名前:デフォルトの名無しさん mailto:sage [2015/11/16(月) 15:01:52.67 ID:mRFC3bAE.net]
- private readonly Dictionary<string,Func<object>> values = new Dictionary<string,Func<object>>();
Hoge(){ string x = 100; this.values[nameof(x)] = () = x; int ans = this.GetValue<int>( nameof( x ) ) * 2; Console.WriteLine( ans ); } T GetValue<T>( string name ) => (T)this.values[name]?.Invoke(); みたいなことをやれば辛うじてできなくはないが、保守性も効率も最悪なので普通はやらない。
|

|