I am trying to make a database of weapons and have multiple attributes assigned to each weapon, such as name, attack value, buy value, sell value, etc.
namespace Testing
{
public class Weapon
{
public string name;
//other attributes would go here too
}
class Program
{
static void WeaponBuilder()
{
Weapon bSword = new Weapon();
bSword.name = "Bronze Sword";
//many other weapons would be built here
Console.WriteLine(bSword.name); //works fine
}
static void Main(string[] args)
{
WeaponBuilder();
Console.WriteLine(bSword.name); //error: bSword does not exist in the current context
WeaponShop();
Console.ReadLine();
}
static void WeaponShop()
{
Console.WriteLine("Buy " + bSword.name + "?"); //error: bSword does not exist in the current context
}
}
}
I need to be able to access the weapon's data outside of where it was constructed. Any help is appreciated. I know this is a noob question and I apologize.