Using C # for the console program in MicroSoft Visual Studio 2010, I made some changes to this with some help from you guys, and this console program works correctly; however, I need to implement a constant static field, which will display the motto “Obey the law of a scout girl” in the output section of the main method. I know this should be something simple, so please bear with me. When I turn on the public static constant string Motto = "Obey the law of the scout girl" in the bass class, I get an error message - the constant "DemoScouts.GirlScout.Motto" cannot be static. Below is the complete code for this project:
public class GirlScout {
public static const string Motto = "To Obey the Girl Scout Law"; public static string scoutName; public static string enterName() { return scoutName; } public static int duesOwed; public static int enterAmount() { return duesOwed; } public static int troopNumber; public static int enterNumber() { return troopNumber; } } class MainClass : GirlScout { static void Main() { Console.WriteLine(); Console.Write("Enter the Girl Scout name: "); GirlScout.scoutName = Console.ReadLine(); Console.WriteLine(); Console.Write("Enter their Troop Number: "); string n = Console.ReadLine(); GirlScout.troopNumber = Int32.Parse(n); GirlScout.enterNumber(); Console.WriteLine(); Console.Write("Enter the amount they Owe in Dues: $"); string d = Console.ReadLine(); GirlScout.duesOwed = Int32.Parse(d); GirlScout.enterAmount(); Console.WriteLine();
}
We welcome all and all sorts of advice.
Rocky source share