return Object<byte> after checking typeof(T) == typeof(byte)
Is this possible or is there a way to sort of do this? I'm trying to do something like this:
6 Replies
Yeah
The constructor takes
Func<string, TValue> fromString
That what I think i'll do, just use object instead of TValueYou can do (TValue)(object)val if (TValue)val doesn’t work.
The JIT recognizes this pattern and will throw away the cast.
It's for a serialisable property
I'm wondering if constrainting TValue to
INumberBase<TValue>
would workDo you actually care if it’s a number, or just if it’s parseable?
Just parsable really
where TValue : IParsable<TValue>
seems to work though
Though not sure if it works at runtime, i have way too many errors at the momentyet another generic bridging problem smh