加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 01:28:25 所属栏目:百科 来源:网络整理
导读:通过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
通过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,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!");
        }
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读