0
Error 1 Cannot implicitly Convert type 'Cursocavancado.Client' to 'string' C: course Cursocavancado Cursocavancado Form1.Cs 47 31 Cursocavancado
Follows the class
namespace CursoCAvancado
{
public partial class Form1 : Form
{
Conta conta;
public Form1()
{
InitializeComponent();
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void Sacar_Click(object sender, EventArgs e)
{
double valor = Convert.ToDouble(txtValorSaque.Text);
this.conta.Saca(valor);
if (valor < 100)
{
MessageBox.Show("Saque efetuado com sucesso" + this.conta.Saldo);
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.conta = new Conta();
this.conta.Titular = new Cliente("everson");
this.conta.Numero = 1;
this.conta.Deposita(100);
txtNumero.Text = Convert.ToString(this.conta.Numero);
txtSaldo.Text = Convert.ToString(this.conta.Saldo);
txtTitular.Text = this.conta.Titular;
}
}
}
classe conta
class Conta
{
public int Numero { get; set; }
public double Saldo { get; set; }
public Cliente Titular { get; set; }
public void Saca(double valor)
{
this.Saldo -= valor;
}
public void Deposita(double valor)
{
this.Saldo += valor;
}
public void Transfere(double valor, Conta destino)
{
}
}
}
Customer class
public class Cliente
{
public string Nome { get; set; }
public Cliente(string nome)
{
this.Nome = nome;
}
}
Everson, try to write a descriptive title and explain your problem and your code better. It’s just [Dit] the question. If you are interested, you have a guide: [Ask].
– brasofilo
txtTitular.Text = this.conta.Titular;
– bfavaretto
I have done more yet so appears the error message, bfavaretto
– Everson Souza de Araujo
What I mean is that the error is in this line. Holder is a client, txtTitular.Text is text. I think you want this.conta.Holder.Name
– bfavaretto
thanks @bfavaretto worked out that was it.
– Everson Souza de Araujo