Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tuple Must Contain at least two elements

Tags:

c#

.net

Going through the Microsoft Documentation and Working through the tutorials, I'm currently working on the Classes and Objects Module.

using System;

namespace classes
{
public class BankAccount
{
    public string Number { get; }
    public string Owner { get; set; }
    public decimal Balance { get; }
    public BankAccount(string name, decimal initialBalance)
    {
      this.Owner = name;
      this.Balance = initialBalance;
    }

    public void MakeDeposit(decimal amount, DateTime date, string note)
    {
    }

    public void MakeWithdrawal(decimal amount, DateTime date, string note)
    {
    }
}

}

is what we start with, and I'm to call upon this class as a test in the Program.cs file

using System;

namespace classes
{
    public class Program
    {
        var account = new BankAccount("<HAMID>", 1000);
        Console.WriteLine($"Account {account.Number} was created for {account.Owner} with {account.Balance} initial balance.");

    }
}

but i get this error in the Console.WriteLine("...")

"Type expected , tuple must be at least two elements, ) expected, invalid token $"Account {account.Number} was created for {account.Owner} with {account.Balance} initial balance."

The link to the article i'm going by is

https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/introduction-to-classes

appreciate any insight on my dilemma.

like image 853
hamdoe Avatar asked Jan 17 '19 21:01

hamdoe


Video Answer


1 Answers

You are missing the static void Main(string[] args) method in your Program class.

Example:

using System;

namespace classes
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}
like image 82
bobek Avatar answered Oct 12 '22 07:10

bobek