Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,47 @@
# Create an Array by separating the elements with commas:
$array = "one", 2, "three", 4
# Using explicit syntax:
$array = @("one", 2, "three", 4)
# Send the values back into individual variables:
$var1, $var2, $var3, $var4 = $array
# An array of several integer ([int]) values:
$array = 0, 1, 2, 3, 4, 5, 6, 7
# Using the range operator (..):
$array = 0..7
# Strongly typed:
[int[]] $stronglyTypedArray = 1, 2, 4, 8, 16, 32, 64, 128
# An empty array:
$array = @()
# An array with a single element:
$array = @("one")
# I suppose this would be a jagged array:
$jaggedArray = @((11, 12, 13),
(21, 22, 23),
(31, 32, 33))
$jaggedArray | Format-Wide {$_} -Column 3 -Force
$jaggedArray[1][1] # returns 22
# A Multi-dimensional array:
$multiArray = New-Object -TypeName "System.Object[,]" -ArgumentList 6,6
for ($i = 0; $i -lt 6; $i++)
{
for ($j = 0; $j -lt 6; $j++)
{
$multiArray[$i,$j] = ($i + 1) * 10 + ($j + 1)
}
}
$multiArray | Format-Wide {$_} -Column 6 -Force
$multiArray[2,2] # returns 33

View file

@ -0,0 +1,46 @@
# An empty Hash Table:
$hash = @{}
# A Hash table populated with some values:
$nfcCentralDivision = @{
Packers = "Green Bay"
Bears = "Chicago"
Lions = "Detroit"
}
# Add items to a Hash Table:
$nfcCentralDivision.Add("Vikings","Minnesota")
$nfcCentralDivision.Add("Buccaneers","Tampa Bay")
# Remove an item from a Hash Table:
$nfcCentralDivision.Remove("Buccaneers")
# Searching for items
$nfcCentralDivision.ContainsKey("Packers")
$nfcCentralDivision.ContainsValue("Green Bay")
# A bad value...
$hash1 = @{
One = 1
Two = 3
}
# Edit an item in a Hash Table:
$hash1.Set_Item("Two",2)
# Combine Hash Tables:
$hash2 = @{
Three = 3
Four = 4
}
$hash1 + $hash2
# Using the ([ordered]) accelerator the items in the Hash Table retain the order in which they were input:
$nfcCentralDivision = [ordered]@{
Bears = "Chicago"
Lions = "Detroit"
Packers = "Green Bay"
Vikings = "Minnesota"
}

View file

@ -0,0 +1,9 @@
$list = New-Object -TypeName System.Collections.ArrayList -ArgumentList 1,2,3
# or...
$list = [System.Collections.ArrayList]@(1,2,3)
$list.Add(4) | Out-Null
$list.RemoveAt(2)