亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用斷點調試時,其余參數正常,,但strlist的值為null?這是哪里錯了?

使用斷點調試時,其余參數正常,,但strlist的值為null?這是哪里錯了?

C# C
HUWWW 2022-06-01 11:07:24
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){}private void button1_Click(object sender, EventArgs e){double corpusAmount, interestRate,interestAmount, incomeAmount;int depositYear; //本金,利率,利息,總收入,存期try // 錄入數據{corpusAmount = double.Parse(this.corpusTextbox.Text);interestRate = double.Parse(this.interestRatetextBox.Text);depositYear = Int32.Parse(this.depositYeartextBox3.Text);}catch //異常處理{MessageBox.Show(" Input dismatached !");return;}incomeAmount = corpusAmount * (Math.Pow((1 + interestRate), depositYear)); //計算總收入interestAmount = incomeAmount - corpusAmount; //計算利息//格式化列表string strList;strList = string.Format(" {0,15:c } {1,15:c } ", interestAmount, incomeAmount);listBox1.Items.Add(strList); //輸出```}}}
查看完整描述

3 回答

?
陪伴而非守候

TA貢獻1757條經驗 獲得超8個贊

c后面 不要空格
double value1 = 16932.456;
double value2 = 15421.354;// {0,15:c } {1,15:c } 這個有空格 錯誤的
string result = String.Format("{0,15:c} {1,15:c}", value1, value2);

查看完整回答
反對 回復 2022-06-06
?
躍然一笑

TA貢獻1826條經驗 獲得超6個贊

strList = string.Format(" {0,15:c } {1,15:c } "
這個是啥?{}里面不是占位符吧
format的用法是string.Format("{0},{1}",value1,value2);
{0}{1}都是占位符,分別對應value1和value2的值

查看完整回答
反對 回復 2022-06-06
?
繁星淼淼

TA貢獻1775條經驗 獲得超11個贊

返回的是2個double數值,一個得息,一個總收到,你用string.Format把他們轉換成字符串,比如一個數是10.59,另一個數是11.49,stringList="10.59$11.49$"(15:C應該表示貨幣吧),你查下interestAmount,和incomeAmount有值么?

查看完整回答
反對 回復 2022-06-06
  • 3 回答
  • 0 關注
  • 160 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號