c# - Why it is not possible to define generic indexers in .NET? -


Why can not you make the genetic indexer in the net?

The following code throws a compiler error:

  public T it & lt; T & gt; [String key] {normal type t. Return}} {/ code>  

Does this mean that you can not create a generic indexer for normal member collection?

The only thing that I can think of is use of these lines:

  var settings = ConfigurationSection.AppSettings; Var connectionString = Settings & lt; String & gt; ["ConnectionString"]; Var Timeout = Settings & lt; Int & gt; ["Timeout"];  

But it does not really buy you anything you have just changed the round legs (as opposed to the [interval] settings ["timeout"]), but you have no additional type Security was not found because you independently

  var timeout = settings & lt; Integer & gt; ["ConnectionString"];  

If you have something that is not strongly but still type fixed, then wait for C # 4.0 with your dynamic keyword You may want to do


Comments