0

「abc;def;ghi」のような値を含むSharePointサイトのユーザープロファイルにResponsibilityという名前のフィールドがあります。これらの値を配列に読み込みたい。[propertyconstants.responsibility] .valueを使用している場合、abcのみが読み取られます。abc、def、ghiを別々に読む方法は?

私のコードは次のとおりです。

string xpUser = up[PropertyConstants.Responsibility].Value.ToString();
string[] expUser = xpUser.Split(';');
4

3 に答える 3

0

私はここであなたがこのようなものを持っていると仮定しています

string xpUser =  "abc; def; ghi";

そして、あなたは阿部、def、ghiを別々にしたいので、このようにします

string[] arrayUser = xpUser.Split(';');
foreach(string user in arrayUser)
{
   //Do what you want with **user** , now this user will have values that you want 1 by 1
   //if you see the value of user, 1st time you will get abc, 2nd time def , 3rd time ghi
}
于 2013-03-22T05:17:10.313 に答える
0

あなたの答えは、トークン「;」で分割したいことを暗示しているようです(「abc」ではなく「abc」が必要だと言ったので)

これを行うことを示す単体テストを次に示します。

 [Test]
 public void SplitStringByString()
 {
    string input = "abc; def; ghi";
    string[] expected = new[] {"abc", "def", "ghi"};

    var result = input.Split(new [] { "; " }, StringSplitOptions.None);

    Assert.That(result, Is.EquivalentTo(expected));
 }
于 2013-03-22T05:19:46.853 に答える
0

助けてくれてありがとう。

私はついに解決策を見つけることができました

 var strUser = up.GetProfileValueCollection(PropertyConstants.Responsibility);
于 2013-03-22T05:46:03.593 に答える