Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
X# examples - Reverse string
Message
De
23/10/2019 05:35:37
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
23/10/2019 02:51:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Divers
Thread ID:
01671628
Message ID:
01671632
Vues:
73
>Hi VFPers,
>
>Thought I will create a new message. And seeing it was discussed in another thread, I thought it might be a good idea to do something similar using some of the features of .NET
>
>Lets look at the basics of reversing a string: "12345" -> "54321", the recursive way. Yes you heard correctly Recursive
>
>
>FUNCTION Reverse(cStr AS STRING) AS STRING
>  RETURN iif(cStr.Length < 2, cStr, Reverse(cStr.Substring(1)) + cStr.Left(1))  && .NET 0 based
>  && The good old XBase alternative
>  RETURN iif(Len(cStr) < 2, cStr, Reverse(SubStr(cStr, 2))  + Left(cStr, 1))
>ENDFUNC
>
>
>Voila 1 line of code to reverse a string

Hey, is it that everything's an object, so you can just say 1234.56.toString() ? ISTR it is so in JavaScript, that even literals are actually objects (of type number, date, string etc).

Note that I had to relearn javascript every 2-3-4 years (used it so often :), and that I managed to push my way to retirement without ever learning .net; I can read C# and it's very amusing, in the amount of dance one has to write to satisfy the compiler. Spoiled by interpretive language, aren't we?

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform