Cov txheej txheem:

Peb puas tuaj yeem siv sim tsis ntes hauv C#?
Peb puas tuaj yeem siv sim tsis ntes hauv C#?

Video: Peb puas tuaj yeem siv sim tsis ntes hauv C#?

Video: Peb puas tuaj yeem siv sim tsis ntes hauv C#?
Video: Ntsaim vaj - Muaj poj niam lawm ua tsis tau li cas ( Official MV ) Nkauj tawm tshiab 2020 2024, Kaum ib hlis
Anonim

Qhov kawg thaiv tsis muaj ib qho rov qab, txuas ntxiv, rhuav cov lus vim nws tsis tso cai rau kev tawm ntawm qhov kawg thaiv. Koj ua tau kuj siv thaum kawg thaiv xwb nrog a sim thaiv txhais tau tias tsis muaj a ntes thaiv tab sis nyob rau hauv qhov teeb meem no, tsis muaj kev zam.

Ib yam li ib tug yuav nug, peb puas tuaj yeem siv sim tsis ntes?

Yog lawm, peb ua tau muaj sim tsis ntes thaiv los ntawm kev siv thaum kawg thaiv. Koj siv tau sim nrog thaum kawg. Raws li koj paub thaum kawg thaiv ib txwm ua haujlwm txawm tias koj muaj kev zam lossis rov qab nqe lus hauv sim thaiv tshwj tsis yog hauv cov ntaub ntawv System.

Tsis tas li ntawd, puas muaj kev sim ntes hauv C? C ++ muab cov ntsiab lus tshwj xeeb hauv qab no rau lub hom phiaj no. sim : sawv cev rau qhov thaiv ntawm cov cai uas tuaj yeem cuam tshuam qhov kev zam. ntes : sawv cev rau qhov thaiv ntawm cov cai uas raug tua thaum muaj qhov tshwj xeeb raug pov tseg. pov: Siv pov ib qho kev zam.

Hauv qhov no, peb puas tuaj yeem sau sim ntes hauv ntes hauv C#?

Nested sim-catch

  • Siv qhov sim, ntes thiab thaum kawg thaiv los daws cov kev zam hauv C #.
  • Lub sim thaiv yuav tsum ua raws li los ntawm kev ntes lossis thaum kawg thaiv lossis ob qho tib si.
  • Muaj ntau qhov thaiv thaiv tau tso cai nrog cov lim dej sib txawv.
  • catch {..} thiab catch (exception exception) { } ob leeg siv tsis tau.

Puas tuaj yeem sim muaj ntau tus ntes hauv C #?

Hauv C# , Koj siv tau ntau tshaj ib ntes block nrog lub sim thaiv. Feem ntau, ntau catch block yog siv los lis ntau hom kev zam txhais tau tias txhua ntes block yog siv los lis ntau hom kev zam. Feem ntau, cov ntes block raug tshuaj xyuas hauv qhov kev txiav txim uas lawv muaj tshwm sim hauv qhov program.

Pom zoo: