Save all types of variables in a vector / array?

2

How can I store values and variables of all types within a vector? Ex:

vetor1.Add("valor em string");
vetor1.Add(100);
vetor1.Add(100.10);
vetor1.Add(-100);

I have no idea how I can do this.

    
asked by anonymous 04.02.2018 / 13:46

1 answer

5

This does not look like an array but a list. The general type for all types is object , so just use it.

var vetor = new List<object>() { "string", 100, 100.10, -100 };
    
04.02.2018 / 13:55