+ 1
Why is C# not smart enough to mix data types in an array? I know MAXscript can mix those.
C and need to declare data types
9 Respostas
0
Why do you need to mix data types In an array?
0
So I can make a list of chars and numbers for example. I have no specific need but was wondering why.
0
Is there no way of creating a custom list? Like a list of vars? Not something I 've ever needed to do, but just thinking out aloud. It doesn't sound like it should be impossible, but maybe there is a more accepted, efficient way? I think I really want to know now.
0
Actually, take a look here, it's quite interesting:
https://stackoverflow.com/questions/4343336/a-list-of-multiple-data-types?answertab=votes#tab-top
0
I'm not familiar with C#, but it's actually really easily done in C, using unions.
https://code.sololearn.com/cBz6fjClRd1R/?ref=app
Here's the Microsoft documentation on C# unions. Not sure if it helps, as I can't read C#.
https://msdn.microsoft.com/en-us/library/bb341731(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
0
you can use tuples to create a collection of different data types. If you have an uncertain number of variables, you can make a list or array of tuples
0
Vlad Serbu that isn't the c# equivalent of c unions (iirc no such thing exists), rather a method that adds two enumerable interfaces together
0
you should use dynamic keyword