c# - Replace extensions in List<String> -
i have next list of strings remove/replace lastly part (i.e. “.mp4\n”) of string string.empty.
list<string> _response [0] ---- “test.mp4\n” [1] ---- “test2.mov\n” [3] ---- “test3.mp4\n” [4] ---- “test3.mp3\n” etc.
how can remove extensions in smart , simple way? i'm using .net 4.0 , i'm new c# , .net.
use path.getfilenamewithoutextension method like:
var newlist = _response.select(r=> path.getfilenamewithoutextension(r.trim())).tolist();
use string.trim
if string ends \n
or shorter form (if file name doesn't contain '\n`):
var newlist = _response.select(path.getfilenamewithoutextension).tolist();
c# .net .net-4.0
No comments:
Post a Comment