Code is not real specific on the screw size or type but I have seen inspectors flag Sheetrock screws in plastic boxes. why? Over tightened the plastic can crack on some boxes. I usually use #8 pan /washer style (modified truss is another name I found them under). the wider head secures the box plastic or metal better than a run of the mill screw. But the reason I started using them is inspectors like them. I use 3/4” or 1” whatever is cheaper sometimes the 1” are.