Hi zendar,

I'd probably use a Choice type here. A Choice type is a discriminated union type which allows you to choose between 2 (or more) values:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
let ByteToString (x:Byte) = Convert.ToString(x)

let StringToByte (x:string) = Convert.ToByte(x)

type MyClass(bytesOrString) = 

    let (hexString, bytes) = 

        match bytesOrString with

        | Choice2_1 bytes -> (ByteToString bytes, bytes)

        | Choice2_2 hexString -> (hexString, StringToByte hexString) 

    member this.Bytes = bytes

    member this.HexString = hexString

//instantiate MyClass

let strInstance = new MyClass(Choice2_2 "a string")

This may not be exactly what you want (I was to lazy to do conversion from string to byte[]...), but it should show the general idea.

BTW, as you can see I have the same problem using formatting as you have. I think though, it has something to do with the browser you use as well...I've had better results using IE.

hope this helps.

By on 12/29/2008 7:59 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper