CS0029:无法隐式转换类型' int'到'字符串'

时间:2015-10-28 21:05:40

标签: c# sum add

protected void btnAdd_Click(object sender, EventArgs e)
{
    int a = Convert.ToInt32(ltAvailable.Text);
    int b = Convert.ToInt32(txtInput.Text);
    ltTotal.Text = a + b;

如何在文字和文本框中添加值?感谢

2 个答案:

答案 0 :(得分:5)

下面:

#include <iostream>
#include "person.h"

using namespace std;

int main()
{
    Person one;

    Person two("Smith");

    Person three("immanuel", "Kant");

    one.Show();
    one.FormalShow();

    two.Show();
    two.FormalShow();

    three.Show();
    three.FormalShow();


    return 0;
}

答案 1 :(得分:0)

protected void btnAdd_Click(object sender, EventArgs e)
{
    int a = Convert.ToInt32(ltAvailable.Text);
    int b = Convert.ToInt32(txtInput.Text);
    ltTotal.Text = (a + b).ToString();

您只需要在计算结果上调用.ToString()

这也可行

ltTotal.Text = Convert.ToString(a + b)
相关问题