Kuv yuav tsum siv GOTO C#?
Kuv yuav tsum siv GOTO C#?

Video: Kuv yuav tsum siv GOTO C#?

Video: Kuv yuav tsum siv GOTO C#?
Video: PRESTIN - Hnub No Koj Yuav Ncaim Mus (Cover) 2024, Kaum ib hlis
Anonim

Tsis muaj dab tsi tsis ncaj ncees lawm goto yog tias siv tau zoo. Yog vim li cas nws yog "taboo" yog vim nyob rau hauv thaum ntxov hnub ntawm C , programmers (feem ntau los ntawm kev sib dhos tom qab) yuav siv goto tsim incredibly nyuaj-to-to taub code. Feem ntau, koj ua tau nyob tsis muaj goto thiab nyob zoo.

Yog li ntawd, vim li cas thiaj li yuav tsum tsis txhob siv GOTO hauv C?

goto nqe lus hauv C . CEEB TOOM- Kev siv goto nqe lus muaj kev poob siab heev nyob rau hauv txhua yam lus programming vim tias nws ua rau nyuaj rau taug qab qhov kev tswj hwm ntawm qhov kev zov me nyuam, ua rau qhov kev pab cuam nyuaj rau kev nkag siab thiab nyuaj rau kev hloov kho. Txhua qhov program ntawd siv a goto tuaj yeem sau rov qab rau zam lawv.

Kuj Paub, qhov teeb meem loj tshaj plaws nrog GOTO nqe lus yog dab tsi? Cov teeb meem nrog siv goto cov lus yog tias nws yog ib qho yooj yim los tsim cov kev pab cuam logic uas nyuaj heev rau kev nkag siab, txawm rau tus thawj sau ntawm cov cai. Nws yog ib qho yooj yim mus ntes tau nyob rau hauv ib tug infinite lub voj yog tias goto point yog saum toj no goto hu.

Ntxiv mus, yog Goto phem xyaum?

Feem ntau cov programmers yuav qhia koj tias qhov GOTO nqe lus yuav tsum zam. Qhov tseeb, nws tsis qhia tawm tsam nws; nws outright hais tias siv nws yog phem programming: "Tau GOTO nqe lus feem ntau suav hais tias yog kev ua haujlwm tsis zoo xyaum uas coj mus rau unwieldy programs. Kev siv nws yuav tsum zam."

GOTO ua dab tsi hauv C?

' goto ' Nqe lus hauv C lus. goto yog jumping nqe lus nyob rau hauv c hom lus, uas hloov qhov kev tswj hwm ntawm ib nqe lus mus rau lwm nqe lus (qhov twg daim ntawv lo yog txhais). goto ua Hloov cov kev pab cuam nyob rau hauv tib lub thaiv thiab yuav tsum muaj ib daim ntawv lo, qhov twg koj xav kom hloov cov kev pab cuam tswj.

Pom zoo: