I have a sample code and some question.
Simple type property
member val CabinetNetworkState : uint8 = 0uy with get, set
member this.CabinetNetworkStateAsValues : (CabinetNetworkStateHosts * uint8) array =
let cabinetNetworkStateMap = new ResizeArray<(CabinetNetworkStateHosts * uint8)> ()
let extNetworkState = (this.CabinetNetworkState >>> 0) &&& uint8 2
match Enum.IsDefined(typeof<CabinetNetworkState>, extNetworkState) with
| true -> cabinetNetworkStateMap.Add (CabinetNetworkStateHosts.EXT, extNetworkState)
| false -> cabinetNetworkStateMap.Add (CabinetNetworkStateHosts.EXT, 0uy)
let canNetworkState = (this.CabinetNetworkState >>> 3) &&& uint8 2
match Enum.IsDefined(typeof<CabinetNetworkState>, canNetworkState) with
| true -> cabinetNetworkStateMap.Add (CabinetNetworkStateHosts.CAN, canNetworkState)
| false -> cabinetNetworkStateMap.Add (CabinetNetworkStateHosts.CAN, 0uy)
let net1NetworkState = (this.CabinetNetworkState >>> 5) &&& uint8 2
match Enum.IsDefined(typeof<CabinetNetworkState>, net1NetworkState) with
| true -> cabinetNetworkStateMap.Add (CabinetNetworkStateHosts.NET1, net1NetworkState)
| false -> cabinetNetworkStateMap.Add (CabinetNetworkStateHosts.NET1, 0uy)
let net2NetworkState = (this.CabinetNetworkState >>> 7) &&& uint8 2
match Enum.IsDefined(typeof<CabinetNetworkState>, net2NetworkState) with
| true -> cabinetNetworkStateMap.Add (CabinetNetworkStateHosts.CAN, net2NetworkState)
| false -> cabinetNetworkStateMap.Add (CabinetNetworkStateHosts.CAN, 0uy)
cabinetNetworkStateMap.ToArray()
What it does it converts a value into array of bit value and enum that value represents My question is should I use Map instead of tuple array, or it does not matter?