Can a list hold multiple data types at the same time?

Can a list hold multiple data types at the same time?

@Shaik_Tharim
welcome to the forum

A list can only hold the items of the datatype of its declared datatype.

We can declare a list of datatype Object and store items of different datatype. But after accessing the item we do need to cast to the right datatype.

Have a look here:
grafik

in some cases the datatype Tuple helps us to store different datatype:
grafik

1 Like

Hi Peter,
Thanks and appreciate your quick response.

So it’s possible to store multiple data type to a list at the same time.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.