locked
how to replace attribute values? RRS feed

  • Question

  • User-737517480 posted
    Hi guys,
    I know that if I can update a property like this:

    If (User.Properties.Contains("test")) Then
        User.Properties("test")(0) = "testing 1" 'Update it
    Else 'It does not exist, so add it
        User.Properties("test").Add("testing 2")
    end if

    However, If i add the values as multiple values,
    e.g. User.Properties("test").AddRange(New Object() {"text 1", "text 2"})
    how can i update it? First remove and then add?  How to do so?

    Friday, June 30, 2006 3:37 AM

All replies

  • User1354132231 posted
    If you want to replace the values, you can either remove all the values and then add the new ones or more easily you can just use the .Value property and set it directly.

    entry.Properties["someAttribute"].Value = new object[] {value1, value2};

    Wednesday, July 5, 2006 9:52 AM
  • User-737517480 posted
    thx a lot.  will try it later today. 

    If you want to replace the values, you can either remove all the values and then add the new ones or more easily you can just use the .Value property and set it directly.

    entry.Properties["someAttribute"].Value = new object[] {value1, value2};

    Wednesday, July 5, 2006 10:13 PM
  • User-973877428 posted

    Thats cool!

     How would I delete a particular value with the multi valued attribute.  I have done this in vbscript for ages but I started vb.net a couple of weeks ago and cant figure out.

     I am using the accountNameHistory field of the computer object (want allowed to create a new one) to store information on build progress, so e.g. I want to write in start time as something like value(x) = "-st;" & now

     If the value is already there I want to clear it first.  In vbscript I was reading the whole attribute into a temp array and manipulating that and writing it back with PutEx, what is the best way in .net, has anyone got any sample code to put me out of my misery?[:P]

     Cheers

     Mike

    Friday, September 15, 2006 3:49 PM