How to create own dynamic type or dynamic object in C#?

dynamic MyDynamic = new System.Dynamic.ExpandoObject(); MyDynamic.A = “A”; MyDynamic.B = “B”; MyDynamic.C = “C”; MyDynamic.Number = 12; MyDynamic.MyMethod = new Func<int>(() => { return 55; }); Console.WriteLine(MyDynamic.MyMethod()); Read more about ExpandoObject class and for more samples: Represents an object whose members can be dynamically added and removed at run time.

What’s the difference between ViewData and ViewBag?

It uses the C# 4.0 dynamic feature. It achieves the same goal as viewdata and should be avoided in favor of using strongly typed view models (the same way as viewdata should be avoided). So basically it replaces magic strings: ViewData[“Foo”] with magic properties: ViewBag.Foo for which you have no compile time safety. I continue … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)