5

consider I have this simple c# code:

dynamic obj = new ExpandoObject();
obj.FirstName = "John";
obj.LastName = "Doe";

I want to add method which will return full name, John Doe in this case. I know the following line will work, but not sure if it is the best aproach

obj.GetFullName = new Func<string>(() => $"{obj.FirstName} {obj.LastName}");

Is there any other way to access dynamic object instance through the GetFullName method?

Arkadi
  • 1,153
  • 1
  • 14
  • 35

0 Answers0