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

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

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

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -