I need to set a variable, based on what’s in a text file.
The text file is set out like this:
AK_47_M,30Rnd_762x39_AK47
AK_47_S,30Rnd_762x39_AK47
AKS_74_Kobra,30Rnd_545x39_AK
bizon_silenced,64Rnd_9x19_SD_Bizon
M1014,8Rnd_B_Beneli_74Slug
M16A2,30Rnd_556x45_Stanag
And so on…
You’ll notice that the first part of that is a weapon class name, and the second is it’s ammunition type’s class name.
I have a comboBox on my form called box_weapon, which reads from the same text file and makes an array of all the first parts of the line by running this code:
string[] weaponsArray = File.ReadAllLines("weapons.txt");
foreach (var line in weaponsArray)
{
string[] tokens = line.Split(',');
box_pw.Items.Add(tokens[0]);
}
To summarize.
I need some kind of “if box_weapon = linePosition1; ammoType = linePosition2”
Try this