So the code is this but I can't figure out the problem. I included the error alongside with it.

using System;

public class SavingAccount
{
   public static decimal interestRate = 0.02M;

   public string Name { get; set; }
   public decimal Balance { get; set; }

   public SavingAccount(string n)
   {
      Name = n;
   }

   public SavingAccount(string n, decimal b)
   {
      Name = n;
      Balance = b;
   }

   public void DisplayInfo()
   {
      Console.WriteLine("Account name: {0}\nAccount balance: {1}\nInterest Rate: {2}", Name, Balance, interestRate);
   }
}

public class Testing
{
   public static void Main(string[] args)
   {
      SavingAccount acct1 = new SavingAccount("Peter Chen");
      SavingAccount acct2 = new SavingAccount("Al Molin", 5000m);
      acct1.DisplayInfo();
      Console.WriteLine();
      acct2.DisplayInfo();
      Console.WriteLine();
      Console.WriteLine("Changing interest rate to 3%");
      SavingAccount.interestRate = 0.03m;
      acct1.DisplayInfo();
      Console.WriteLine();
      acct2.DisplayInfo();
      Console.WriteLine();
   }
}

Error 1 'Main': member names cannot be the same as their enclosing type

Any idea what the problem is. I looked through it a hundred times.

You must have a problem somewhere else, because I took your code as is, and it compiled and ran fine. Hope this helps and good luck.

how do i clean a build, because i went to BUILD > clean solution > than hit f7 again to rebuilt but nothing happened

This article has been dead for over six months. Start a new discussion instead.