VydrOz
VydrOz
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
yep OkCursor
19 replies
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
and separate the class Animal (without "s") in an other file
19 replies
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
i guess you are learning to code, but if you put everything in the Program.cs, it is a good practice to put the main method on top
19 replies
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
otherwise the code seems correct
19 replies
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
you need to add using System; to call Console.WriteLine()
19 replies
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
feelsniceman np
19 replies
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
19 replies
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
Declaring a variable means to introduce a new variable to the program. You define its type and its name. Instantiate - Instantiating a class means to create a new instance of the class.
19 replies
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
declaration : List<KeyValuePair<string, int>> list; instantiation : list = new List<KeyValuePair<string, int>>();
19 replies
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
you must instantiate your list variable externally OR pass it directly into the method and return it / using reference
19 replies
CC#
Created by DiMiaN on 3/12/2023 in #help
✅ How to add data to a list that is outside of Main()?
yes cause you declare it in the method insertData, So list is not accessible in main
19 replies