Dab tsi yog chav kawm dav dav hauv C #?
Dab tsi yog chav kawm dav dav hauv C #?

Video: Dab tsi yog chav kawm dav dav hauv C #?

Video: Dab tsi yog chav kawm dav dav hauv C #?
Video: Wb zaj dab neeg sib hlub tsis tau (Full version) - ZAJ DUB nkauj tawm tshiab 2024, Hlis ntuj nqeg
Anonim

Ntau yog a chav kawm uas tso cai rau tus neeg siv los txhais chav kawm thiab cov txheej txheem nrog rau qhov chaw. Ntau yam tau ntxiv rau version 2.0 ntawm C# lus. Lub tswv yim yooj yim tom qab siv Ntau yog tso cai hom (Integer, String, … thiab lwm yam thiab cov neeg siv txhais hom ) los ua ib qho parameter rau txoj kev, chav kawm , thiab interfaces.

Ib yam li ntawd, dab tsi yog chav kawm dav dav hauv C # nrog piv txwv?

Ntau yam cia koj txhais a chav kawm nrog placeholder rau hom ntawm nws cov teb, txoj kev, tsis, thiab lwm yam. Ntau yam hloov cov chaw tuav nrog qee yam tshwj xeeb ntawm lub sijhawm sau. A chav kawm dav dav tuaj yeem txhais tau siv lub kaum sab xis.

Qhov thib ob, cov chav kawm generic yog dab tsi? Cov chav kawm dav dav yog chav kawm uas coj ib hom raws li ib tug parameter. Lawv muaj txiaj ntsig tshwj xeeb rau kev sau chav kawm.

Ib yam li ntawd, nws raug nug, dab tsi yog txoj hauv kev hauv C#?

A txoj kev generic yog a txoj kev uas tau tshaj tawm nrog hom tsis muaj, raws li hauv qab no: C# Luam. static void Swap(ref T lhs, ref T rhs) { T temp; temp = lhs; lhs = rhs; rhs = temp; } Cov piv txwv hauv qab no qhia ib txoj hauv kev hu rau txoj kev los ntawm kev siv int rau hom kev sib cav: C# Luam.

Dab tsi yog qhov txawv ntawm kev sau thiab generics hauv C #?

Luv luv, qhov yooj yim qhov sib txawv ntawm generic thiab tsis- generic collections : - Generic collections - Cov no yog cov kev sau uas tuaj yeem tuav cov ntaub ntawv tib yam thiab peb tuaj yeem txiav txim siab seb hom ntaub ntawv twg kev sau tau tuav. Qee qhov zoo ntawm generic collections - Hom kev nyab xeeb, ruaj ntseg, txo nyiaj siv ua haujlwm ntawm hom kev hloov pauv.

Pom zoo: