© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•14mo ago•
12 replies
hugeman

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:
if (typeof(TValue) == typeof(sbyte)) {
    return new MyObject<sbyte>(defaultValue, getValue, setValue, (x) => sbyte.Parse(x));
}
if (typeof(TValue) == typeof(sbyte)) {
    return new MyObject<sbyte>(defaultValue, getValue, setValue, (x) => sbyte.Parse(x));
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

✅ typeof()?
C#CC# / help
2y ago
❔ Why is typeof(T).FullName a ``string?``, but typeof(T).Name a ``string``
C#CC# / help
3y ago
Get the bytes of byte[] as string
C#CC# / help
3y ago
Condense Byte[] to BitArray to smaller Byte[]
C#CC# / help
4y ago