© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
26 replies
0_00

how to set enum type based on what child class is used

I have the public enum
public enum WorkerType{
    Worker,
    Associate,
    Supervisor
}
public enum WorkerType{
    Worker,
    Associate,
    Supervisor
}

and I'm making a method to set the enum based on which child class is called. So if class1 is called it will set the enum to worker, if class2 (child of class 1 with inherited variables) it sets to associate etc. I want to set my method up like
public void setWorkerType(){
    if (class = class1){
      this.WorkerType = WorkerType.Worker
}
public void setWorkerType(){
    if (class = class1){
      this.WorkerType = WorkerType.Worker
}

but my issue is that im not sure how to set up my if statement so that the class is checked is class1 or not.
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

Update an enum in a child class
C#CC# / help
2y ago
How to activate Child Class?
C#CC# / help
13mo ago
Enum based Singleton
C#CC# / help
2y ago
Casting object to enum class
C#CC# / help
2y ago