预期的字符串长度为51,但为7。字符串在索引0处不同。如何克服此问题

时间:2018-08-18 05:30:51

标签: c#-4.0

/ *我试图创建并显示具有ID,帐户类型和余额的简单帐户详细信息。在运行该程序时,我得到一个输出,但输出的是预期的字符串长度51,但为7。字符串在索引0处不同。如何克服这种类型的错误?* /

<div id="rectangle" style="display: flex; justify-content: center;"> 

<img class="logo" src="Untitled.png">
</div>
    <style> 

        .logo {
            position: relative; 
            width: 35%;
            top: -5px;
            height: auto;
            text-align:center;
        }

        #rectangle {
        
            width: 100%;
            height:100px;
            background:#101010;
            position: fixed;
            top: 0;

        }


    </style>

/ 在主要方法中,我创建了一个构造函数并获取用户输入 /

using System;

//class with private fields, properties and methods

public class Account{

private int id;
private String accountType;
private double balance;

public int Id { 
    set{
        id=value;
    }
    get{
        return id;
        }
}

public String AccountType { 
    set{
        accountType = value;
    }
    get{
        return accountType;

    }
}

public double Balance { 
    set{
        balance = value;
    }
            get{
        return balance; 
    }
}

public Account(int Id,String AccountType,double Balance)
{
    this.Id = Id;
    this.AccountType = AccountType;
    this.Balance = Balance;
}

public bool Withdraw(double amount){
    if(balance>amount){
     balance-=amount; 
    return true; 
    }
    else{
          return false;    
    }
}
//Displaying the details 
public String GetDetails(){
    Console.WriteLine("Account Id: {0}",Id);
    Console.WriteLine("Account Type: {0}",AccountType);
    Console.WriteLine("Account Balance: {0}",Balance);
    return accountType;
}
}

0 个答案:

没有答案