Zināšanu bāze

Code complete (Izstrādātāja ikdiena).

Labdien,

Apmulsu ar kādiem tempiem sāk pildīties mūsu zināšanas bāze. Nav vēlmes palikt malā:)

Tiecoties uz perfektu kodu, šoreiz par vienu interesantu vadlīniju. Reāls uzdevums no dzīves.

· Tiek padota simbolu kopa (String)

· Jāpārbauda vai simbolu kopa satur tikai burtus.

Prātā nāk vismaz divas realizācijas.

· Izmantot regulārās izteiksmes. Ja tās jūs pārzināt, tas neaizņems daudz laika. Bet kods ir jāraksta, pastāv arī kļūdas iespēja;

· Uzrakstīt ciklu. Apskatam katru simbolu uz atbilstību atļautiem simboliem. Šinī gadījumā visticamāk jūsu kods būs jāatkļūdo un jāuztur;

Bet vai pastāv arī alternatīvāki varianti, ar domu maksimāli koncentrētos uz pārbaudes nosacījuma! Šeit var palīdzēt jaunā All paplašinošā metode System.Linq vardu telpā. Kas ir domāta objektiem, kas manto IEnumerable interfeisu.

Tātad varam uzrakstīs šādu te kodu, tas atbilst mūsu uzdevumam. Kods ir maksimāli īss, un šeit ir pavisam niecīga iespēja kļūdīties.

using System.Linq;
...
var s = "ABC";
var result = s.All(Char.IsLetter);
...

Veicu veiktspējas testus, stipri neatpaliek no varianta, kad tiek rakstīts savs cikls, bet noteikti ir ātrāks par regulārām izteiksmēm.

Cerams, noderēs.


Posted Nov 04 2008, 07:12 PM by andrejs.mamontovs

Comments

ivars.arins wrote re: Code complete (Izstrādātāja ikdiena).
on 11-05-2008 8:43

Papildus stila punktus saņemtu par konstrukciju

var result = "ABC".All(Char.IsLetter);

:)

andrejs.mamontovs wrote re: Code complete (Izstrādātāja ikdiena).
on 11-06-2008 9:56

Galvenā doma bija parādīt darbību ar mainīgo. Reālos gadījumos tas tiek aizpildīt ar vērtību no kādas teksta ievades kontroles.

Rayshelon wrote re: Code complete (Izstrādātāja ikdiena).
on 11-09-2011 12:45

You're a real deep thinker. Thanks for shriang.

Bookmarking Service wrote re: Code complete (Izstrādātāja ikdiena).
on 08-08-2012 12:21

XlTBlm Im grateful for the blog post.Thanks Again. Really Cool.

crork wrote re: Code complete (Izstrādātāja ikdiena).
on 11-09-2012 0:06

EQ8TQq A big thank you for your article.Much thanks again. Want more.

Seo Service wrote re: Code complete (Izstrādātāja ikdiena).
on 12-08-2012 18:00

MnD8hl Im obliged for the blog. Much obliged.

la redoute soldes wrote re: Code complete (Izstrādātāja ikdiena).
on 02-11-2013 6:40

Contentment is actually a perfume you cannot flood on some people and it doesn't involve looking for a small number of declines on one self. la redoute soldes www.b22.fr/lunettes-c-22.html

archeage power leveling wrote re: Code complete (Izstrādātāja ikdiena).
on 02-26-2013 16:37

I constantly emailed this website post page to all my contacts, as if like to read it then my links will too. archeage power leveling www.cheap-archeage-gold.com/archeage-power-leveling.html

Tous les prix wrote re: Code complete (Izstrādātāja ikdiena).
on 03-05-2013 21:05

I'm sure happened as a what you do, although as a which one I am certain when I have always been in your wallet. Tous les prix http://www.g33.fr/

paristreet wrote re: Code complete (Izstrādātāja ikdiena).
on 03-14-2013 18:06

Will be survive each time per chum senses he has a slight high quality throughout the other useful. paristreet http://www.a88.fr/

casquette monster wrote re: Code complete (Izstrādātāja ikdiena).
on 03-15-2013 19:26

Those that may take care of your formula of an opponent, determine the situation to never someone. casquette monster http://www.b44.fr/

casquette superman wrote re: Code complete (Izstrādātāja ikdiena).
on 03-15-2013 19:36

Basically no man or woman might be worth your primary tears, and also a person that is really got‘w not allow you to be cry out. casquette superman http://www.b77.fr/

casquette new era wrote re: Code complete (Izstrādātāja ikdiena).
on 03-16-2013 23:33

Please don't bring all your contentment to 1 significantly less lucky besides your lifestyle. casquette new era http://www.a77.fr/

Destockchine wrote re: Code complete (Izstrādātāja ikdiena).
on 03-19-2013 5:47

When you would have to retain the key by way of an opponent, convey to it again this is not to a person. Destockchine www.ruenike.com/chaussure-femme-c-4.html

social bookmarking service wrote re: Code complete (Izstrādātāja ikdiena).
on 03-23-2013 0:30

s1cjES Looking forward to reading more. Great blog.Much thanks again. Much obliged.

casquette new era wrote re: Code complete (Izstrādātāja ikdiena).
on 04-06-2013 16:27

Even if someone doesn‘MT accept you how want them so that you,doesn‘MT necessarily suggest these products get into‘MT accept you using they have. casquette new era http://www.ruetn.fr/

Add a Comment

(obligāts)  
(brīvizvēles)
(obligāts)  
Remember Me?