title: Take variable from class in another class
body: <p>Good day,
  i read this topic: <a href="https://stackoverflow.com/questions/22216253/access-variable-from-another-method-in-another-class#">Access variable from another method in another class</a> but its not helping for me.</p>
  
  <p>My Class (config.cs in Controlcenter.Data) looks like this:</p>
  
  <pre><code>public class config
  {
      public string conn;
      private MySqlConnection connect;
      public void db_connection()
      {
          conn = "Server=localhost;Database=csharptest;Uid=root;Pwd=";
          connect = new MySqlConnection(conn);
          connect.Open();
      }
  }
  </code></pre>
  
  <p>In frmLogin.cs (Controlcenter.ConsoleApp) i can take the Metho db_connection:</p>
  
  <pre><code>config myclass = new config();
  myclass.db_connection();
  </code></pre>
  
  <p>All fine.
  So my test connection code in frmLogin.cs is working:</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      try
      {
          config myclass = new config();
          myclass.db_connection();
          MessageBox.Show("Erfolg");
      }
      catch (MySqlException ex)
      {
          MessageBox.Show(ex.Message);
      }
  }
  </code></pre>
  
  <p>But now I want to do a loginscript whos not working cuz frmLogin.cs cant find "conn" and "connect" from config.cs</p>
  
  <pre><code>private bool validate_login(string user, string pass)
  {
      connect_db();
      MySqlCommand cmd = new MySqlCommand();
      cmd.CommandText = "SELECT * FROM users where username=@user and password=@pass";
      cmd.Parameters.AddWithValue("@user", user);
      cmd.Parameters.AddWithValue("@pass", pass);
      cmd.Connection = connect;
      MySqlDataReader login = cmd.ExecuteReader();
      if (login.Read())
      {
          connect.Close();
          return true;
      }
      else
      {
          connect.Close();
          return false;
      }
  }
  </code></pre>
  
  <p>How can I take the variables from config.cs into frmLogin.cs ?</p>