0

What is wrang?

If account is a class and arr_list is list array , X=0; arry_list ={"hi",111,4.5}; Double V; V=account.arr_list[x+2];

29th Aug 2021, 5:44 PM
Almasa Sense
Almasa Sense - avatar
13 RĂ©ponses
+ 1
Almasa Sense You need to cast it to its original type string item1 = (string) array_list[0]; int item2 = (int) array_list[1]; double item3 = (double) array_list[2]
30th Aug 2021, 4:40 AM
Tim
Tim - avatar
+ 4
namespace Sololearn { class account{ public static int[] a={"hi",111,4.5}; } class Program { static void Main(string[] args) { int x=0; Double V; V=account.a[x+2]; } } }
29th Aug 2021, 6:03 PM
Abhay
Abhay - avatar
+ 2
Almasa Sense You might want to store the elements in a non-generic collection, such as ArrayList, object[], or List<object>, the first one is not recommended though due to performance issue Hope this helps 👍
29th Aug 2021, 7:02 PM
Tim
Tim - avatar
+ 2
Calm down, it's just a question
1st Sep 2021, 3:06 PM
Tim
Tim - avatar
+ 2
Almasa Sense Ever considered using a Struct or a Class? Then you can store the class objects in an array or a list later on
1st Sep 2021, 3:37 PM
Tim
Tim - avatar
+ 1
GDSHNIK Why enum?
1st Sep 2021, 3:01 PM
Tim
Tim - avatar
+ 1
It's simpler. And you can put ANY of variables
1st Sep 2021, 3:03 PM
GDSHNIK
GDSHNIK - avatar
+ 1
And don't call it like only int[] or List<int>()
1st Sep 2021, 3:03 PM
GDSHNIK
GDSHNIK - avatar
+ 1
Class
1st Sep 2021, 3:39 PM
Almasa Sense
Almasa Sense - avatar
0
What is the other way to get a value from an array?
29th Aug 2021, 10:21 PM
Almasa Sense
Almasa Sense - avatar
0
As I understand it, we cannot mix various types of values in array. So { "hi", 111, 4.5 } itself may require extra work/research to accomplish.
30th Aug 2021, 1:07 AM
Ipang
0
Just make enumerator, and then you can put variables, and set elements directly or in declaring. enum a ={Integer=111,str = "Hi", Doublev = 4.5};
1st Sep 2021, 3:00 PM
GDSHNIK
GDSHNIK - avatar
0
I work in project to college i have a lot variables to insert like name, age and so on .the project have a 10 tasks so i use list array
1st Sep 2021, 3:29 PM
Almasa Sense
Almasa Sense - avatar