Two-dimensional layered materials are widely used due to their favorable electrical and optical properties. In this paper, the electronic structure, DOS, charge transfer, and optical properties of the defect state C-MX2 system of transition state metal-sulfur compounds are investigated using first-principle calculations. The electronic structure, DOS, charge transfer and optical properties of three systems, MoS2, MoTe2 and WS2, are systematically compared and analyzed. The results show that MoS2, MoTe2, and WS2 are all direct band-gap semiconductors. After the occurrence of vacancy defects, MoTe2 and WS2 are transformed from direct band-gap to indirect band-gap, while MoS2 still maintains the direct band-gap. We chose C atoms to dope the defective state MX2 system. After doping with a low concentration of C atoms, the Fermi energy level decreases, the valence band shifts upward, and the system undergoes a semiconductor-to-metal transition. In terms of density of states, the Mo-d and W-d orbitals as well as the S-p and Te-p orbitals are gradually enhanced under the effect of defect states and C doping, with the contribution of MoTe2>MoS2>WS2. In terms of optical properties, the absorption and reflection peaks of all three systems are blue-shifted after the change of defect states and C doping.