Results 1 to 2 of 2

Thread: Replace function for System.Array

  1. #1
    jviper is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Nov 2005
    Posts
    12
    Reputation
    105

    Replace function for System.Array

    Hello. as you may know the Strings class has a Replace function which is designed to replace all of a charactor/string that exists in a string you specify. What I want is a similar function that for example takes an array of integers, searches the array for an integer value I specify, and replaces all of them with that integer. Problem is, looping through all of the items in the array is too slow. Is there a way to do this without having to loop through the entire array?

  2. #2
    Tom
    Tom is offline VB.NET Forum Idol
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Aug 2005
    Posts
    746
    Reputation
    385
    Use the Array.IndexOf property to search an array

    intResult = Array.IndexOf(YourArray, ValueToFind)

    If intResult >= 0 then

    YourArray(IntResult) = NewValue

    End If

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking