By means of first-principles calculations, we predict an all-sp3 hybridized tetragonal BC2N compound (tet-BC2N) which is suggested to be obtained by transversely compressing (4,0) carbon nanotubes (CNTs) and boron nitride nanotubes (BNNTs) arrays. Accompanied by the transition from sp2-hybridized nanotubes to sp3-hybridized tet-BC2N, not only the bond length and diameter of tubes but also the electronic bandgap increases. Strikingly, the bandgap of the tet-BC2N can be mediated by controlling the ratio of BNNTs to total nanotubes from 1/2 to 1. However, it is almost a constant for the ratio changing from 0 to 1/2. In addition, this study shows that the tet-BC2N is a potential material for chemical hydrogen storage. While the weight percentage of hydrogen storage is up to 3.9 wt%, the adsorbed hydrogen still exists in the form of molecules. Even if the weight percentage of hydrogen storage increases to 7.6 wt%, the tet-BC2N is still intact but partial hydrogen molecules split into atoms.