I want to use textBox1.Text
in a different class not just in the main where the text boxes are defined so to say. Is there any way to make it global? Because it only allows me to use it in the main thing, not in the seperate class that I have to make in my task.
I need to store the text from the textBox
in a List
that is in a different class so the user can't add the same name twice so I need to remember what was typed in in the first input.
This is the class where I created a List
and where I want to store those inputs:
internal class Clanovi
{
public static List<Clan> Dodaj()
{
List<Clan> clanovi = new List<Clan>();
clanovi.Add(new Clan() { KorIme = textBox1.Text, Lozinka = textBox2.Text });
return clanovi;
}
}
class Clan
{
public string KorIme { get; set; }
public string Lozinka { get; set; }
}
This is WinForm btw.