question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Complex to implement IConvertible

See original GitHub issue

Hi,

I have a scenario where the return type of a formula is not known in advance. Hence, I would like to write something like this :

Type t = GetTheReturnType(); // ex: typeof(int)
return Convert.ChangeType(resultAsComplex.ToNumber(), t);

This would require the Complex type to implement IConvertible.

public partial record Complex : Number, IConvertible

I noticed that implicit operators for conversion are already in place so implementing the interface is feasible. Anyone has some feedback on this proposition ?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tongbongcommented, Apr 16, 2021

Yes that is what I did.

1reaction
WhiteBlackGoosecommented, Apr 16, 2021

Alright, let’s keep the issue here for now, until it’s 100% clear. @tongbong, for now you can apply the idea with an extension method for your project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IConvertible Interface (System)
Defines methods that convert the value of the implementing reference or value type to a common language runtime type that has an equivalent...
Read more >
c# - Implementing IConvertible interface
I have custom type named LocalizedString and I need to implement IConvertible interface since when we serialize types to our DB we use ......
Read more >
How to implement IConvertible interface
IConvertible interface defines methods that convert the current instance to a language runtime type. using System;//from j a v a 2s .c o...
Read more >
Object must implement IConvertible in Power Apps
So taking “Object must implement IConvertible” back into Power Platform language: The TextInput control returns information that cannot be used ...
Read more >
IConvertable exception
I've faced with a problem on binding XRSubreport parameters. Steps to reproduce: Create Subreport with one parameter "TypeParm" (complex value).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found