From 40c17b6ba1d34cdf09f836ffcd16523adbcf47da Mon Sep 17 00:00:00 2001 From: "Travis J. Terrell" Date: Wed, 2 Jan 2019 16:51:42 -0600 Subject: [PATCH] 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 --- docs/how-to-setup-freecodecamp-locally.md | 4 +-- guide/english/csharp/list/index.md | 39 +++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 guide/english/csharp/list/index.md diff --git a/docs/how-to-setup-freecodecamp-locally.md b/docs/how-to-setup-freecodecamp-locally.md index baafd92235..5b2b33f9c9 100644 --- a/docs/how-to-setup-freecodecamp-locally.md +++ b/docs/how-to-setup-freecodecamp-locally.md @@ -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:** diff --git a/guide/english/csharp/list/index.md b/guide/english/csharp/list/index.md new file mode 100644 index 0000000000..fdbe97ec6c --- /dev/null +++ b/guide/english/csharp/list/index.md @@ -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 = new List();` + +Here are examples of how lists would be initialized for a few different data types: +`List = new List();` +`List = new List();` +`List = new List();` + +## 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 = new List { 11, 22, 33, 44, 55, 66 }; +``` +``` +List myClass = new List +{ + new MyClass(){ Id = 1, Name = "First" }, + new MyClass(){ Id = 2, Name = "Second" }, + new MyClass(){ Id = 3, Name = "Third" }, +}; +``` \ No newline at end of file