Salve ho fatto un overload ma non riesco a mantenere il valore nella variabile s1.
codice:
private void btnSomma_Click(object sender, EventArgs e)
{
double op1;
op1 = Convert.ToDouble(op1Txt.Text);
ClassOperazioni sommatoria = new ClassOperazioni(op1);
}
private void btnUguale_Click(object sender, EventArgs e)
{
double x = 0;
int c = Convert.ToInt32(x);
double op2;
op2 = Convert.ToDouble(op1Txt.Text);
ClassOperazioni sommatoria2 = new ClassOperazioni(op2,c);
op1Txt.Text = Convert.ToString(sommatoria2.Somma());
}
codice:
public ClassOperazioni(double a)
{
som0 = a;
}
public ClassOperazioni(double b, int c)
{
som00 = b; som1 = c;
}
public double Somma1()
{
double s1 = som0;
return s1 ;
}
public double Somma2()
{
double s2 = som00;
return s2;
}
public double Somma()
{
double somma =(Somma1() + Somma2());
return somma;
}
Qualcuno ha qualche idea?
Grazie.