Hi Robert, Chris and Team,
I have a small problem / issue and need some help please.
I am researching Collections, LINQ and Lambda Expressions, with Anonymous Types, for my Cologne 2018 eNotes and also "ClickStartXSharp".
I have a method returning a DYNAMIC collection from a LINQ query. This is then bound to a 'DataGrid' on a WPF form - it seems to work nicely, as one of the images shows - see below :-
Now then, all I wished to do was to see what Type of object I was passing by first showing on a MessageBox the result of a ToString() on the object passed. I thought that 'ToString()' always worked, with everything !?
Here is what I got from the compiler :-
Please can you have a quick look at the images (and code) to see if I may be doing something silly or wrong. If there is a need for you to have code and script then I will send a full small project - I will make one from the test and trial code (currently messy) I have been working on.
TIA.
Regards,
Phil.
ToString - not working with DYNAMIC ?
ToString - not working with DYNAMIC ?
Phil,
You need to add a reference to the assembly Microsoft.CSharp
This works if you include the Microsoft.CSharp Library
Robert
You need to add a reference to the assembly Microsoft.CSharp
This works if you include the Microsoft.CSharp Library
Code: Select all
FUNCTION Start() AS VOID
LOCAL d AS DYNAMIC
d := Person{}
d:FirstName := "Phil"
d:LastName := "Hepburn"
Console.WriteLine("Hello {0}", d)
Console.ReadKey()
CLASS Person
PROPERTY FirstName AS STRING AUTO
PROPERTY LastName AS STRING AUTO
METHOD ToString() AS STRING
RETURN FirstName+" "+LastName
END CLASS
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
ToString - not working with DYNAMIC ?
Hi Robert,
THANKS for the quick reply - and I am now up and running.
I can now adjust my eNotes etc..
Here is a picture of success :-
What was misleading me was that the original object printed out from inside the generating method, but then of course it was not of Type 'DYNAMIC'.
Thanks once again,
Cheers,
Phil.
Wales, UK.
THANKS for the quick reply - and I am now up and running.
I can now adjust my eNotes etc..
Here is a picture of success :-
What was misleading me was that the original object printed out from inside the generating method, but then of course it was not of Type 'DYNAMIC'.
Thanks once again,
Cheers,
Phil.
Wales, UK.
ToString - not working with DYNAMIC ?
Hi Robert,
I tried the code you provided, referenced Microsoft.CSharp.dll but I still get error XS0656 (see att.). What I am missing?
Compiler: 2.0.0.8
X#/Core
no compiler switches set
Regards,
Stefan
I tried the code you provided, referenced Microsoft.CSharp.dll but I still get error XS0656 (see att.). What I am missing?
Compiler: 2.0.0.8
X#/Core
no compiler switches set
Regards,
Stefan
- Attachments
-
- XSharp_DynamicTest2.JPG (60.81 KiB) Viewed 729 times
ToString - not working with DYNAMIC ?
Hi Stefan,
Did you add a reference to the Microsoft.CSharp in the solution explorer. It is not enough to insert a USING statement.
Jamal
Did you add a reference to the Microsoft.CSharp in the solution explorer. It is not enough to insert a USING statement.
Jamal
ToString - not working with DYNAMIC ?
Hi Jamal,
yes it was referenced. If not there would be error XS0234 (missing reference).
But System.Core also has to be referenced. Then it compiles and runs.
Stefan
yes it was referenced. If not there would be error XS0234 (missing reference).
But System.Core also has to be referenced. Then it compiles and runs.
Stefan
ToString - not working with DYNAMIC ?
Hi Stefan,
I must admit I was just caught by the same thing as well
Chris
I must admit I was just caught by the same thing as well
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
ToString - not working with DYNAMIC ?
Hi Stefan,
But System.Core is added automatically when you create a new project. How could it be missing?
I am using X# beta 8 with VS 2017 build 15.9.6
Jamal
But System.Core is added automatically when you create a new project. How could it be missing?
I am using X# beta 8 with VS 2017 build 15.9.6
Jamal
ToString - not working with DYNAMIC ?
Hi Jamal,
I am using XIDE. It's lightweight and also runs on Surface Go. I am using VS2017 only for C# and Visual Basic stuff.
Stefan
I am using XIDE. It's lightweight and also runs on Surface Go. I am using VS2017 only for C# and Visual Basic stuff.
Stefan