© 2026 Hedgehog Software, LLC

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

❔ How to access variable from another class?

I wanna access int level from ability.cs to main.cs, but I have no idea how to do that.

{
    
    public class Ability
    {
        public  int level;


        public class passiveAbility : Ability
        {
            public void Dodge()
            {
                level = 2;
            }
        }
        
        public class activeAbility : Ability
        {

        }
        
    }
}
{
    
    public class Ability
    {
        public  int level;


        public class passiveAbility : Ability
        {
            public void Dodge()
            {
                level = 2;
            }
        }
        
        public class activeAbility : Ability
        {

        }
        
    }
}
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

❔ Accessing variable from another class
C#CC# / help
3y ago
❔ ✅ Access variable from another script
C#CC# / help
3y ago
❔ How to access variable from AccessibilityObject ?
C#CC# / help
3y ago
How to refer to the mainwindow class from another class.
C#CC# / help
2y ago