-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Original (incorrect) text :
Example 5: Generate two objects of different object types
PS C:\>"123 456" | ConvertFrom-String -PropertyNames String,IntThis command generates an object with default property names P1 and P2, but property types String and Integer are identified. The results are P1=123 and P2=456. The second property is an integer, not a string.
I've validated that this is true:
In this example, both FirstWord and SecondWord are already byte and int16.
C:\WINDOWS\system32> "123 456" | ConvertFrom-String -PropertyNames FirstWord,SecondWord | Get-Member
TypeName: System.Management.Automation.PSCustomObject
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
FirstWord NoteProperty byte FirstWord=123
SecondWord NoteProperty int16 SecondWord=456
In Example 5, the order switches because of alphabetization, and 123 misleadingly looks like a "byte String", but it's actually just a byte called String (just like above):
C:\WINDOWS\system32> "123 456" | ConvertFrom-String -PropertyNames String,Int | gm
TypeName: System.Management.Automation.PSCustomObject
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Int NoteProperty int16 Int=456
String NoteProperty byte String=123
Metadata
Metadata
Assignees
Labels
No labels