The dynamic
type indicates that use of the variable and references to its members bypass compile-time type checking. Instead, these operations are resolved at run time. The dynamic
type simplifies access to COM APIs such as the Office Automation APIs, to dynamic APIs such as IronPython libraries, and to the HTML Document Object Model (DOM).
Here is an example;
var list = new List<dynamic>();
dynamic row = new ExpandoObject();
row.AccountNumber = "XYZ-331";
row.FYQ = "Q3 FY 2021";
row.DateAdded = "2021-07-28 19:38:00.000";
row.RowStatus = "processed";
list.Add(row);
Here is the output;
list.ForEach(x =>
{
Console.WriteLine($"AccountNumber = { x.AccountNumber} \nFYQ = {x.FYQ}\nDateAdded = {x.DateAdded}\nRowStatus = {row.RowStatus}");
});
Resources
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/reference-types
https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.expandoobject?view=net-5.0
https://www.codegrepper.com/code-examples/csharp/add+static+data+to+list+in+c%23
Add to favorites