vb.net - How could I get the first and last letters from a string? -
how can program take first , last letters entered string?
example: "i've been told noob!"
output: "iebntdiaman!"
i tried use split no luck.
try this. since have couple of single character words used conditional in order desired output. using string.split
method removes empty entries in order prevent 0 length item, taking result , using string.substring
method parse out starting , ending chars.
sub main() dim splitchar string() = {" "} dim example string = " i've been told noob!" dim output string = "" dim result string() = example.split(splitchar, stringsplitoptions.removeemptyentries) each item in result if item.length > 1 output += item.substring(0, 1) & item.substring(item.length - 1, 1) else output += item.substring(0, 1) end if next console.writeline(output) console.readline() end sub
Comments
Post a Comment