-1

我需要用位置值替换下面的代码值。

string str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ; 
DN = str.replaceAll( "Code" , LOCATION ) ;

我得到的方法签名不正确,因为字符串定义包含 "=" 和 "," 符号。有什么帮助吗?

谢谢。

4

2 回答 2

1
string str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ; 

看起来不对。“字符串”不是一个类。它必须是Stringdef。像下面

 String str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ; 

或者

 def str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ; 
于 2016-02-03T03:53:34.223 回答
0

无需设置错误的字符串,然后使用替换来使其正确。

只需使用模板来创建正确的字符串。IE:

String DN = "OU=Contractors,OU=Users,OU=$LOCATION,OU=Sites,DC=xyz,DC=com"
于 2016-02-03T08:25:34.083 回答