当前位置 : 主页 > 编程语言 > c语言 >

c# – 元组必须包含至少两个元素

来源:互联网 收集:自由互联 发布时间:2021-06-25
通过Microsoft文档和完成教程,我目前正在研究类和对象模块. using System;namespace classes{public class BankAccount{ public string Number { get; } public string Owner { get; set; } public decimal Balance { get; } public Ba
通过Microsoft文档和完成教程,我目前正在研究类和对象模块.

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)
    {
    }
}

}

是我们开始的,我将调用此类作为Program.cs文件中的测试

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.");

    }
}

但我在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."

我要去的文章的链接是

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

欣赏有关我的困境的任何见解.

您缺少Program类中的静态void Main(string [] args)方法.

例:

using System;

namespace classes
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}
网友评论