c# - Splitting a string in the format domain\alias -
this question has answer here:
- how split string multiple values? 5 answers
i have user input variable containing string in format: "domain\alias"
, need split in 2 different strings: domain , alias.
i heard somewhere conversion of strings literals don't understand how me here.
write
var x = @"doamin\alias".split('\\')
it give array whith contents
x[0] = "doamin" x[1] = "alias"
if want user if domain isn't specified:
var user = x.length == 2 ? x[1] : x[0]; var domain = x.length == 2 ? x[0] : null;
Comments
Post a Comment