© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
8 replies
IceReaper

❔ How to calculate with numbers which are typed as object?

I have a function which gets a List<object> parameter. Several different sources are actually adding a value to the list, which might be anything from byte to decimal. Basicaly any buildin number type. Im trying to calculate using the values in the list, one after another. However its not possible to simply to "a + b" if both are only known as "object". I could ofcourse do 15 * 15 type checks (possible number types) for a and b, just to be able to sum them and get the appropriete result (int + int = int, int + float = float, ...). Is there any better solution to this at all? Help would be very appreciated!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Create JSON object with numbers as names
C#CC# / help
4y ago
❔ How to calculate event expression?
C#CC# / help
3y ago
✅ Familiarity with `YamlDotNet` package, parsing to strongly typed object keeps failing
C#CC# / help
3y ago
How are people dealing with mapping from a class object to generated object from protobuf?
C#CC# / help
2y ago