Last active
December 30, 2015 00:29
-
-
Save s0ren/7749563 to your computer and use it in GitHub Desktop.
Afkortning af tekst. C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (tekstSomSkalKlippes.Length > maxLængde) | |
{ | |
return tekstSomSkalKlippes.Substring(0, maxLængde); | |
} | |
else | |
{ | |
return tekstSomSkalKlippes; | |
} | |
// eller som metode: | |
public static string klip(String tekstSomSkalKlippes, int maxLængde) | |
{ | |
if (tekstSomSkalKlippes.Length > maxLængde) | |
{ | |
return tekstSomSkalKlippes.Substring(0, maxLængde); | |
} | |
else | |
{ | |
return tekstSomSkalKlippes; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment