C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Merging Two String Array


Posted Date: 27 Aug 2008    Resource Type: Code Snippets    Category: String Manipulations

Posted By: Ritesh N. Jain       Member Level: Gold
Rating:     Points: 10



Below function can be used to merge two string array,This function will combine two string array into one,eleminating duplicate element.


'Pass the Destination and Source string array that need to be merged
Private Function MergeArray(ByVal arrDestination() As String, ByVal arrSource() As String) As String()
Dim intElement As Integer
Try
For intElement = 0 To arrSource.Length - 1
'Check if element already exist,in no Re-Dimension the Destination array and add the New element in it.
If Array.IndexOf(arrDestination, arrSource(intElement)) = -1 Then
ReDim Preserve arrDestination(arrDestination.Length)
arrDestination(arrDestination.Length - 1) = arrSource(intElement)
End If
Next
'Return the Resultant mergred array
Return arrDestination
Catch exc As Exception
Throw exc
End Try
End Function

'e.g
Dim arrArray1() As String = {"My", "Name"}
Dim arrArray2() As String = {"Name", "Is", "ABC"}
'After mergin above array the fginal value in arrArray1 will be {"My,"Name", "Is", "ABC"}
arrArray1 = MergeArray(arrArray1, arrArray2)


PS:Same logic can be used to merge anytype of array.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Merging Two Array  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: string type in C#.NET
Previous Resource: C# code for string comparision
Return to Discussion Resource Index
Post New Resource
Category: String Manipulations


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use