c# - Why can I not use dynamic? -


this question has answer here:

i trying simple data series test andeverything working intended, want switch

list<datetime> events = new list<datetime>(); 

to

list<dynamic> events = new list<dynamic>(); 

when switch list dynamic getting these 2 errors. "one or more types required compile dynamic expression cannot found. missing reference?" , these 2 errors occuring on console.writeline

any idea how can output list dynamic?

here's code:

 [testmethod]         public void timeseriesdata()         {             list<dynamic> events = new list<dynamic>();             var stream = new             {                 id = 15,                 name = "streama" + 15,                 typeid = "typea"             };             _server.poststream(stream);              datetime starttime = datetime.today;  //  12:00             datetime endtime = datetime.today; // 12:00 +1 sec             endtime = endtime.adddays(1);             endtime=endtime.addseconds(1);              (int = 0; < 3000; i++)             {                 if (i % 2 == 0) //is                 {                     var datastart = new                     {                         timeid = starttime.addseconds(i),                         valuestart =                     };                      events.add(starttime.addseconds(i));                 }                  else  //is odd                 {                     var dataend = new                     {                         timeend = endtime.addseconds(-i),                         valueend =                      };                     events.add(endtime.addseconds(-i));                 }               }              foreach (var item in events)                 console.writeline("time: {0} ", item.tostring()); } 

not sure, works fine:

        var l = new list<dynamic>();         l.add(new {dt=datetime.now});         l.add(datetime.now);          foreach (var o in l)         {             console.writeline(o.tostring());         } 

your code compiles , runs fine on machine.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -