Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // How to set lists
- // Lists are important for holding an int or a string as a list.
- // Example:
- List<int> list = new List<int>(); // This is a list called list, and each list has to be an int
- // How to use lists
- // You can add items to a list, or remove items, a list is treated like a collection of items. ( Items can be ints, strings, etc.)
- // For example:
- list.Add(7); // I've added the number 7 as a list.
- list.Add(25); // Now I've added the number 25 as a new list.
- list.Remove(7); // Now I've removed the list that contained '7'
- // There are many things you can do with lists, such as count the number of items in the list
- Console.WriteLine(list.Count); // Console is the Output window, where you can make the program show results.
- // You use Console.WriteLine() to make the program write text to Output.
- // Count is a function that counts the total number of items in a collection.
- Output:
- 3 // This is the value you would receive in Output
- // You can use classes to get multiple values and set them as one object
- class numset
- {
- public int one { get; set; }
- public int two { get; set; }
- public int three { get; set; }
- }
- List<numset> newlist = new List<numset>();
- newlist.Add(new numset{ 1, 2, 3 }; // Add three values as one list using a class struct
- // There are a lot of uses for lists, and arrays (which I might write a pastebin on), but I'm at school so lol
- // Hope you understood something about lists :D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement