Cannot apply indexing with [] to an expression of type ‘System.Dynamic.DynamicObject’
Have you tried ViewBag.SuccessBody = TempData[“successBody”];
Have you tried ViewBag.SuccessBody = TempData[“successBody”];
I believe you’d be interested in the ExpandoObject class. The DynamicObject class is just a base where you’re meant to provide all the logic. It explicitly implements the IDictionary<string, object> interface so you can access it properties or add new ones that way. // declare the ExpandoObject dynamic expObj = new ExpandoObject(); expObj.Name = “MyName”; … Read more
Expando is a dynamic type to which members can be added (or removed) at runtime. dynamic is designed to allow .NET to interoperate with types when interfacing with dynamic typing languages such as Python and JavaScript. So, if you need to handle a dynamic type: use dynamic and if you need to handle dynamic data … Read more
You could serialize to an intermediate format, just to deserialize it right thereafter. It’s not the most elegant or efficient way, but it might get your job done: Suppose this is your class: // Typed definition class C { public string A; public int B; } And this is your anonymous instance: // Untyped instance … Read more
Jahamal’s answer doesn’t say why you get the error. The reason is that the anonymous class is internal to the assembly. Keyword dynamic doesn’t allow you to bypass member visibility. The solution is to replace the anonymous class with named public class. Here’s another good example explaining the reason and another possible solution. The reason … Read more
The dynamic keyword is used to declare variables that should be late-bound. If you want to use late binding, for any real or imagined type, you use the dynamic keyword and the compiler does the rest. When you use the dynamic keyword to interact with a normal instance, the DLR performs late-bound calls to the … Read more