简体   繁体   中英

How to access an array of another form in C#?

I've just started learning how to code in C# and I'm trying to make a program that should help learning french vocabulary.

Since I'm not good in SQL-Databases yet, I'm using a VocabArray and a TransArray to define the vocabulary.

In the next step, I want to add a new word. I'm doing that through two text boxes that should add their string to the array in the main form. But how do I access the array from the main form through the textboxes in my new form?

Other than the fact an array doesn't really support your purpose ( Dictionary<string, string> or List<Tuple<string, string>> would be better) You can just make a static variable like so:
internal static string[] arr = {"something", "something else"};
Put this in the class but outside the methods

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM