Type definition with a property that is an interface

I am looking for functional equivalence for the following C # code:

public virtual ICollection<Dog> Dogs { get; set; }

      

I've worked up and down SO and MSDN to no avail. Is there another construct for properties other than this:

let mutable dogID = 0

member public self.DogID
    with get() = dogID
    and set(value) = dogID <- value

      

+3


source to share


2 answers


You can use automatic properties:



member val Dogs = List<Dog>() with get,set 

      

+3


source


OK, apparently I need SO (verb) to be even better. I found this this one which led me to this:

let mutable dogs = List<DOG>() :> ICollection<DOG> 


member public self.Dogs
    with get() = dogs
    and set(value) = dogs <- value      

      



Thanks to Dave for pointing me to the explicit class. Also, Genesh, I think this is your question? Thanks for the help.

+2


source







All Articles