the object datatype is the closest to the vb variant.
// explicit
object a = 10; // int (boxed)
a = "abc"; // now string
// var
var b = new object();
b = 10; // now int (boxed)
b = "abc"; // now string
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
What is the equivalent of VBA's variant data type for C#?
the object datatype is the closest to the vb variant.
// explicit
object a = 10; // int (boxed)
a = "abc"; // now string
// var
var b = new object();
b = 10; // now int (boxed)
b = "abc"; // now string