Search code examples
c#visual-studiopublic

How to transfer a value from public(that i got from another form) to other functions?


I want to get the value from Übergabe_Darkmode that could be the value = 1. And i want to use it in the function: Einzelspieler_Load

namespace Schiffe_versenken
{
    public partial class Einzelspieler : Form
    {       
        public Einzelspieler(int Übergabe_Darkmode)
        {
            InitializeComponent();
            this.MaximizeBox = false; 
            this.MinimizeBox = false; 
        }

        private void Einzelspieler_Load(object sender, EventArgs e)
        {
            if(Übergabe_Darkmode == 1)
            {
                MessageBox.Show("Hui");
            }

Solution

  • namespace Schiffe_versenken
    {
      public partial class Einzelspieler : Form
      {       
        public Einzelspieler(int Übergabe_Darkmode)
        {
            InitializeComponent();
            this.MaximizeBox = false; 
            this.MinimizeBox = false;
            darkmode = Übergabe_Darkmode;
        }
    
        private int darkmode { get; set; }
    
        private void Einzelspieler_Load(object sender, EventArgs e)
        {
            if(darkmode == 1)
            {
                MessageBox.Show("Hui");
            }