Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - List/Collection of references to Properties -


consider these properties,

        double _temperature;         public double temperature         {             { return _temperature; }             set { _temperature = value; }         }         double _humidity;         public double humidity         {             { return _humidity; }             set { _humidity = value; }         }         bool _israining;         public bool israining         {             { return _israining; }             set { _israining = value; }         } 

and want make list/collection/container of properties this,

propertycontainer.add(temperature);  //line1 propertycontainer.add(humidity);     //line2 propertycontainer.add(israining);    //line3 

i want make such later on may able access current values of properties using index, this,

object currenttemperature =  propertycontainer[0]; object currenthumidity    =  propertycontainer[1]; object currentisraining   =  propertycontainer[2]; 

but obviously, not going work, since propertycontainer[0] return old value - value temperature had @ time of adding temperature container (see line1 above).

is there solution problem? want access current values of properties uniformly; thing can change is, index. index string well.

ps: don't want use reflection!

well, use lambdas:

list<func<object>> propertyaccessors = new list<func<object>>(); propertyaccessors.add(() => this.temperature); propertyaccessors.add(() => this.humidity); propertyaccessors.add(() => this.israining); 

then this:

object currenttemperature = propertyaccessors[0](); 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -