Net Remove The Duplicate String Of A String Array

11.08.2019
  1. Net Remove The Duplicate String Of A String Array Line

How to check duplicates in string array c#.Also show a message if duplicate present. Posted 14-Apr-13 21:37pm. So you'd probably want to remove punctuation characters from the original string, or remove them when adding them to either the hset and the duplicates collections. Lastly, punctuation in a sentence can obfuscate duplicate words, so you'd probably want to remove punctuation characters from the original string, or remove them when adding them to either the hset and the duplicates collections (in the example above).

I need some help figuring out how to remove duplicates from an array. I've been working on this for a few days now, and every time I think I'm getting close, it just causes my program to shut down.

String

I've gt a text file with city names in it and mileage distances between the cities. But the cities are listed more than once. So out of 4 cities, I currently have an array with 12 elements. I need to remove the duplicates.

I'm not asking for someone to write the code for me... Just a little help on how to go about ignoring/removing the duplicates, so that I can end up with an array of just 4 unique city names. I'm still pretty new at this, sorry if this is a really basic question.

Net Remove The Duplicate String Of A String Array Line

Thanks a lot, for any help!

-Charles...

  • 3 Contributors
  • forum5 Replies
  • 393 Views
  • 16 Hours Discussion Span
  • commentLatest Postby VernonDozier

The easiest was is not to put the duplicates in the array in the first place. When you read a city name from the file check to see if the name is already in the array. If not, then add it.

P: n/a
Nyazi.
Use the way that I gave you with the Datatable where I gave you pseudo
because I did not know you were using VBNet..
Bassicly it is like this, the only thing is that you have to add your
counting fields.
http://www.vb-tips.com/default.aspx?...2-1a580eb893b2
I hope this helps, and please don't start a new thread, Greg would not know
that I wrote this already to you and that you are in fact busy with a
datatable.
Cor
'Niyazi' <Ni****@discussions.microsoft.com> schreef in bericht
news:39**********************************@microsof t.com...
Hi all,
What is fastest way removing duplicated value from string array using
vb.net?
Here is what currently I am doing but the the array contains over 16000
items. And it just do it in 10 or more minutes.
'REMOVE DUBLICATED VALUE FROM ARRAY +++++++++++++++++
Dim col As New Scripting.Dictionary
Dim ii As Integer = 0
For ii = 0 To DTHESNO_ARRAY.Length - 2
If Not col.Exists(CStr(DTHESNO_ARRAY(ii))) Then
col.Add(CStr(DTHESNO_ARRAY(ii)), ii)
End If
Next
ReDim _DTHESNOKR102A(col.Count - 1)
'ASSIGN NONE DUPLIATED VALUT TO STRING ARRAY ++++++++
Dim iii As Integer = 0
For iii = 0 To col.Count - 1
_DTHESNOKR102A(iii) = col.Keys(iii)
Next
'NOW SORT THE STRING ARRAY ++++++++++++++++++++++++++
Array.Sort(_DTHESNOKR102A)
col = Nothing
Is it possible to clone the col to the _DTHESNOKR102A(col.Count - 1)
Thank you very much for reading my post.
Rgds,
GC

Comments are closed.