Hello,
I have an array of data.
And I want to know how can I detect duplicate and/or wrong data in array.

This is my array of data:
135N258S
135N269B
136N112S
136N123D
135N269B
136K225D
136N124S
136N269B

This data is OK.
135N258S
135N269B
136N112S
136N123D
136N124S
136N269B

Wrong data is wrong when middle letter (like K or any other) is in this array.
Also, wrong data is when we have duplicate values such as 135N269B but not wrong if we have 136N269B.

If you have an idea, or somekind php or visual C# example, I would appreciate your help.

'>Thanks
BP

Recommended Answers

All 2 Replies

Start by completing your design specification. You gave a start where you told what was good and bad along with duplicate removals but stopped short of telling what should happen as well as if this was to "read a file, write to another file with the filtered, tested data."

So for you to begin, write a basic file reader that reads your lines and prints them on screen and to the second file. Once you have that then you add functions to test for good or bad. Later you can add a function to test for duplicates.

I have her a small snip that might put you onthe way:

 static void Main(string[] args)
        {
            string[] input = {
                "135N258S",
                "135N269B",
                "136N112S",
                "136N123D",
                "135N269B",
                "136K225D",
                "136N124S",
                "136N269B"};

            var dataOK = input.Distinct().Where(n => !n.Contains("K"));
            foreach (string str in dataOK)
            {
                Console.WriteLine(str);
            }
            Console.ReadKey();
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.