feat: add c# guide for lists (#33787)
* feat: add c# guide for lists * fix: minor grammar fix on how-to-steup-freecodecamp-locally * fix: corrected typo
This commit is contained in:
parent
bebf3af072
commit
40c17b6ba1
@ -113,8 +113,8 @@ Start by installing these prerequisite software.
|
||||
|
||||
| Prerequisite | Version | Notes |
|
||||
| ------------------------------------------- | ------- | ----- |
|
||||
| [MongoDB Community Server](https://docs.mongodb.com/manual/administration/install-community/) | `3.6` | [Release Notes](https://docs.mongodb.com/manual/release-notes/), Note: We currently on `3.6`, an [upgrade is planned](https://github.com/freeCodeCamp/freeCodeCamp/issues/18275).
|
||||
| [Node.js](http://nodejs.org) | `8.x` | [LTS Schedule](https://github.com/nodejs/Release#release-schedule), Note: We currently on `8.x`, an upgrade is planned to 10.x |
|
||||
| [MongoDB Community Server](https://docs.mongodb.com/manual/administration/install-community/) | `3.6` | [Release Notes](https://docs.mongodb.com/manual/release-notes/), Note: We are currently on `3.6`, an [upgrade is planned](https://github.com/freeCodeCamp/freeCodeCamp/issues/18275).
|
||||
| [Node.js](http://nodejs.org) | `8.x` | [LTS Schedule](https://github.com/nodejs/Release#release-schedule), Note: We are currently on `8.x`, an upgrade is planned to 10.x |
|
||||
| npm (comes bundled with Node) | `6.x` | Does not have LTS releases, we use the version bundled with Node LTS |
|
||||
|
||||
**Important:**
|
||||
|
39
guide/english/csharp/list/index.md
Normal file
39
guide/english/csharp/list/index.md
Normal file
@ -0,0 +1,39 @@
|
||||
---
|
||||
title: Lists
|
||||
---
|
||||
|
||||
# Lists
|
||||
|
||||
A list is a data structure that holds variables in a specific order. It can hold any type of variable, and the type is defined when initializing the list.
|
||||
|
||||
A list is similar to an array, but unlike arrays, which must have a fixed size, lists are dynamically sized. This is useful if you do not know the number of variables that will be included, or if additional variables will be added in the future.
|
||||
|
||||
## Initializing a list
|
||||
Lists are initialized using the following format:
|
||||
`List<type> = new List<type>();`
|
||||
|
||||
Here are examples of how lists would be initialized for a few different data types:
|
||||
`List<int> = new List<int>();`
|
||||
`List<string> = new List<string>();`
|
||||
`List<MyCustomPoCo> = new List<MyCustomPoCo>();`
|
||||
|
||||
## Adding items to a list
|
||||
Items can be added to the list using the following syntax.
|
||||
`List.Add(ItemToAdd)`
|
||||
|
||||
For example:
|
||||
`List.Add(33)`
|
||||
`List.Add("I am a string.")`
|
||||
|
||||
It is also possible to use the object initializer format to initialize a list with a set of data.
|
||||
```
|
||||
List<int> = new List<Int> { 11, 22, 33, 44, 55, 66 };
|
||||
```
|
||||
```
|
||||
List<MyClass> myClass = new List<MyClass>
|
||||
{
|
||||
new MyClass(){ Id = 1, Name = "First" },
|
||||
new MyClass(){ Id = 2, Name = "Second" },
|
||||
new MyClass(){ Id = 3, Name = "Third" },
|
||||
};
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user