Variant Type in C#

void upDateRTB(object z) {
    MessageBox.Show(this, "amount; " + Convert.ToString(z));
}

If you're talking about "variant" type in c#, take a look at dynamic type in .net 4.0

But for solving your task it would be enough to use z.ToString() in your MessageBox.Show


An object parameter would accept all, but if you'd like to keep the variables strongly typed (and avoid boxing in the process), you could use generics:

void upDateRTB<T>(T z) {
    MessageBox.Show(this,"amount; "+ Convert.ToString(z)); 
}

The method calls could remain precisely the same, because the compiler can resolve the generic type based on the given parameter.

Tags:

C#

Types