Skip to content

Commit 01616ab

Browse files
return byte array from function
1 parent f5e18ea commit 01616ab

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function make-byteArray() {
2+
3+
[outputType( [byte[]] )]
4+
5+
[byte[]] $byteArray = new-object byte[] 2
6+
7+
$byteArray[0] = 0
8+
$byteArray[1] = 1
9+
10+
write-host "type of byteArray: $($byteArray.GetType().FullName)"
11+
12+
return $byteArray
13+
}
14+
15+
$x = make-byteArray
16+
write-host "type of x: $($x.GetType().FullName)"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# https://stackoverflow.com/a/61440166/180275
3+
#
4+
function make-byteArray() {
5+
6+
[outputType( [byte[]] )]
7+
8+
[byte[]] $byteArray = new-object byte[] 2
9+
10+
$byteArray[0] = 0
11+
$byteArray[1] = 1
12+
13+
,$byteArray
14+
}
15+
16+
$x = make-byteArray
17+
write-host "type of x: $($x.GetType().FullName)"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# https://stackoverflow.com/a/61440506/180275
3+
#
4+
function make-byteArray() {
5+
6+
[outputType( [byte[]] )]
7+
8+
[byte[]] $byteArray = new-object byte[] 2
9+
10+
$byteArray[0] = 0
11+
$byteArray[1] = 1
12+
13+
write-output -noEnumerate $byteArray
14+
}
15+
16+
$x = make-byteArray
17+
write-host "type of x: $($x.GetType().FullName)"

0 commit comments

Comments
 (0)