Nanowire electronic and optoelectronic devices