I have a razor string
@postername.Substring(0, @postername.IndexOf("@"))
If the username has email I get the username before @ sign but if the username doesn’t have email I want to have that whole word, how to do ?
if(@postername.Contains("@")){
@postername.Substring(0, @postername.IndexOf("@"))
}else{
@postername
}
but didn’t work, pls help
If you must do this at View level, build the logic into a variable first:
Then call the new variable: