SyntaxFix
Write A Post
Hire A Developer
Questions
You can do it:
var str = "Doctor Who,Fantasy,Steven Moffat,David Tennant"; var title = str.Split(',').First();
Also you can do it this way:
var index = str.IndexOf(","); var title = index < 0 ? str : str.Substring(0, index);