c# - Splitting a string in the format domain\alias -


this question has answer here:

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

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -