Hi Robert, Chris and Team,
I have a small problem / issue and need some help please.
I wish to be able to write code so that a cast I make can be done in a general way and not by me typing a specific class name / type. The attached very small image will help explain what I am after.
In line 114 I wish to provide a variable name and not 'Double' - as in the end I am to make some very general code where the Type comes in as a parameter, or Generic type.
I seem to have tried most things with Type and typeof() and GetType() etc., but have not coded as yet in a Generic fashion.
What is the correct and proper way to do this ?
HELP !!! please,
Phil.
Casting - the general case etc.
Casting - the general case etc.
Phil,
What are you trying to do ?
If you want to create a method that takes "any type" you should use a generic type parameter:
Robert
What are you trying to do ?
If you want to create a method that takes "any type" you should use a generic type parameter:
Robert
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
Casting - the general case etc.
Hi Robert,
Yes, thanks - I now have my "foot in the door" to solving my problem.
This is what I have done to research my possible solution.
I think this approach should solve my problems !?
Although what I am doing is an interesting X# coding challenge, it may not be of much day-to-day use to many / any folks.
However, I have built a basic class wrapper around the System.Array class so that I now have a functioning single array class which allows any value index limits. The test class worked for STRING and I was trying to convert it to accept any array item class.
Nearly there I feel.
Project task is a good one to help improve our X# syntax 'mastery' - so don't say its a waste of time. And, it makes some useful code to include in the ClickStartXSharp eNotes.
More on this stuff when I get it to work 100%
Thanks for trying to help.
Cheers,
Phil.
Yes, thanks - I now have my "foot in the door" to solving my problem.
This is what I have done to research my possible solution.
I think this approach should solve my problems !?
Although what I am doing is an interesting X# coding challenge, it may not be of much day-to-day use to many / any folks.
However, I have built a basic class wrapper around the System.Array class so that I now have a functioning single array class which allows any value index limits. The test class worked for STRING and I was trying to convert it to accept any array item class.
Nearly there I feel.
Project task is a good one to help improve our X# syntax 'mastery' - so don't say its a waste of time. And, it makes some useful code to include in the ClickStartXSharp eNotes.
More on this stuff when I get it to work 100%
Thanks for trying to help.
Cheers,
Phil.