DYNAMIC Lists, and Anonymous Types

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

DYNAMIC Lists, and Anonymous Types

Post by Phil Hepburn »

Hi Robert, Team and guys,

I have acted on your recent code suggestions Robert and have come up with an improved version of my first tries with List<DYNAMIC>. See attached function.

So my next efforts, this morning, then went into trying to access the elements in my dynamic List. With the idea of grabbing one and then doing something with it, and its properties.

I have had some success, but only if I cast the collection items (elements) to type Object.

I have struggled in my usual way to get other things to work - BUT - get some messages back from the compiler that I don't understand - when it seems to me that the simple ToString() code should work.

Have you or anyone else on the Team got any ideas ?
TIA,
DynamicLists_01.jpg
DynamicLists_01.jpg (54.23 KiB) Viewed 363 times
DynamicLists_02.jpg
DynamicLists_02.jpg (95.34 KiB) Viewed 363 times
DynamicLists_03.jpg
DynamicLists_03.jpg (67.86 KiB) Viewed 363 times
Cheers,
Phil.
User avatar
robert
Posts: 4567
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

DYNAMIC Lists, and Anonymous Types

Post by robert »

Phil,

You will have to include the Microsoft.CSharp assembly in the references list of your app.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

DYNAMIC Lists, and Anonymous Types

Post by Phil Hepburn »

Thanks Robert,

Thought it may be something easy ;-0)

Now all works as I would wish - can access the property values in each of the returned collection elements (or items).
See attached image test.

Best regards,
Phil.
DynamicLists_04.jpg
DynamicLists_04.jpg (91.4 KiB) Viewed 363 times
P.S. X# eNotes on LINQ and related topics is going well - see second image of the contents of a large appendix added to my C# eNotes of 4.5 years back.
DynamicLists_04.jpg
DynamicLists_04.jpg (91.4 KiB) Viewed 363 times
XSharpAppendix_02.jpg
XSharpAppendix_02.jpg (98.68 KiB) Viewed 363 times
Post Reply