© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
9 replies
Velcer

❔ Continue a switch statement

The switch statement is very convenient for managing my types.

I would like to instead of just having one of these hit, for it to hit any that meet criteria.

            switch (kinematic)
            {
                case PlayerShip playerShip:
                    playerShipsEnteredProximityOfEntity.Add(new KeyValuePair<ushort, ushort> (kinematic.KinematicId, collision.Id));
                    break;
                case BaseEntity entity:
                    if (!entity.EntitiesInProximity.Contains(collision.Id))
                        entity.EntitiesInProximity.Add(collision.Id);
                    break;
            }
            switch (kinematic)
            {
                case PlayerShip playerShip:
                    playerShipsEnteredProximityOfEntity.Add(new KeyValuePair<ushort, ushort> (kinematic.KinematicId, collision.Id));
                    break;
                case BaseEntity entity:
                    if (!entity.EntitiesInProximity.Contains(collision.Id))
                        entity.EntitiesInProximity.Add(collision.Id);
                    break;
            }
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

❔ alternative to switch statement or if statements?
C#CC# / help
4y ago
❔ Comparison in switch statement
C#CC# / help
4y ago
❔ How to shorten switch statement
C#CC# / help
3y ago