© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•17mo ago•
101 replies
BlandLife

Building Constructors 101

Not to familiar with C# personally but I'm using it with Unity for a project-based class I'm taking. I'm trying to build a state machine, where there's the
BaseState
BaseState
interface and
StateMachine
StateMachine
class. In my
StateMachine
StateMachine
class I have a constructor that takes a
BaseState defaultState
BaseState defaultState
parameter. I want it to be able to take classes that implement/inherit from the
BaseState
BaseState
interface like
IdleState
IdleState
or
PatrolState
PatrolState
, but I really don't have a clue how to do that.
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

✅ Constructors
C#CC# / help
3y ago
Sloppy Constructors
C#CC# / help
15mo ago
Constructors, Classes
C#CC# / help
16mo ago
Next page