Delete duplicate rows from Multidimensional Object array [,]?

Ranju

Let's Assume I have Multi dimensional Object array that represents simple matrix

 Object[,] mybaseobject = new object[,] { 
             {"Rakesh", "Martin", "21"},
             {"Rohith", "M", "22"},
             {"Rakesh", "Martin", "21"},
             {"varsha", "MJ", "18"},

Even if String object[,] also fits fine for my project

It Object array looks like

Rakesh      Martin     21
Rohith       M          22  
Rakesh      Martin     21
Rohith       M          22
varsha       Mj         18
Rohith       M          22

Please find me way to delete duplicate rows and make array to look like this?

Rakesh      Murthy     21
Rohith       M          22
varsha       Mj         18

I am using this approach [one of existing approach in stack over flow forum ][1]

Delete duplicate rows from two dimentsional array

But in abovelink works fine for Multidimensional Integer data I need solution for Multidimensional object array[,]

Please help me out thanks(+1) in advance

Kvam

As others have pointed out, you may not want to work with object[,]. Below is an implementation that transforms the object[,] to List<object[]>, performs filtering on that, then transforms the List<object[]> back to a two dimensional array.

void Filter()
{
    Object[,] mybaseobject = new object[,]
    { 
        { "Ranjith", "Murthy" }, 
        { "Rohith", "M" }, 
        { "Ranjith","Murthy" }, 
        { "varsha", "MJ" }
    };

    var objectList = AsList(mybaseobject);

    var distinctLines = new List<object[]>();

    foreach (var line in objectList)
    {
        if (!distinctLines.Any(x => x.SequenceEqual(line)))
        {
            distinctLines.Add(line);
        }
    }

    var filteredobjects = AsTwoDimentionalArray(distinctLines);
}

private List<object[]> AsList(object[,] input)
{
    var lines = new List<object[]>();
    for(var i = 0; i < input.GetLength(0);++i)
    {
        var line = new List<object>( input.GetLength(1));
        for (var j = 0; j < input.GetLength(1); ++j)
        {
            line.Add(input[i, j]);
        }
        lines.Add(line.ToArray());
    }
    return lines;
}

private object[,] AsTwoDimentionalArray(List<object[]> input)
{
    var result = new object[input.Count(), input[0].Length];
    for (var i = 0; i < input.Count; ++i)
    {
        for(var j = 0; j < input[0].Length; ++j)
        {
            result[i, j] = input[i][j];
        }
    }
    return result;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to delete duplicate elements in a multidimensional array?

From Dev

Delete duplicate rows from dataset

From Dev

creating an multidimensional Object dynamically from an multidimensional array

From Dev

Remove duplicate values from a multidimensional array in PHP

From Dev

How to remove duplicate values from a multidimensional array?

From Dev

Remove duplicate combination of elements from multidimensional array

From Dev

Remove duplicate values from a multidimensional array

From Dev

Merge and add duplicate integers from a multidimensional array

From Dev

remove duplicate values from multidimensional array

From Dev

Disregard both duplicate entries from multidimensional array

From Dev

How to remove duplicate entries from multidimensional array?

From Javascript

Delete duplicate elements from an array

From Javascript

Delete Array Element From Multidimensional Infinity Array

From Dev

mysql delete duplicate rows from table

From Dev

Delete duplicate rows from table with no unique key

From

Delete duplicate rows from a BigQuery table

From

Delete duplicate rows from small table

From Dev

Delete duplicate rows from SELECT query?

From Dev

Delete Oldest Duplicate Rows from a BigQuery Table

From Dev

How to delete duplicate rows from mysql

From Dev

Delete object from array

From Dev

Delete unwanted arrays from multidimensional array

From Dev

Multidimensional array remove duplicates from columns and rows

From Dev

Indexing and retrieving numpy rows from a multidimensional array

From Dev

Delete duplicate value from array of array

From Dev

Remove Duplicate from Array of Object

From Dev

Characters duplicate in a multidimensional array

From Dev

Delete the duplicate words from array of strings in MySQL

From Dev

how to delete duplicate records from array of objects?

Related Related

  1. 1

    How to delete duplicate elements in a multidimensional array?

  2. 2

    Delete duplicate rows from dataset

  3. 3

    creating an multidimensional Object dynamically from an multidimensional array

  4. 4

    Remove duplicate values from a multidimensional array in PHP

  5. 5

    How to remove duplicate values from a multidimensional array?

  6. 6

    Remove duplicate combination of elements from multidimensional array

  7. 7

    Remove duplicate values from a multidimensional array

  8. 8

    Merge and add duplicate integers from a multidimensional array

  9. 9

    remove duplicate values from multidimensional array

  10. 10

    Disregard both duplicate entries from multidimensional array

  11. 11

    How to remove duplicate entries from multidimensional array?

  12. 12

    Delete duplicate elements from an array

  13. 13

    Delete Array Element From Multidimensional Infinity Array

  14. 14

    mysql delete duplicate rows from table

  15. 15

    Delete duplicate rows from table with no unique key

  16. 16

    Delete duplicate rows from a BigQuery table

  17. 17

    Delete duplicate rows from small table

  18. 18

    Delete duplicate rows from SELECT query?

  19. 19

    Delete Oldest Duplicate Rows from a BigQuery Table

  20. 20

    How to delete duplicate rows from mysql

  21. 21

    Delete object from array

  22. 22

    Delete unwanted arrays from multidimensional array

  23. 23

    Multidimensional array remove duplicates from columns and rows

  24. 24

    Indexing and retrieving numpy rows from a multidimensional array

  25. 25

    Delete duplicate value from array of array

  26. 26

    Remove Duplicate from Array of Object

  27. 27

    Characters duplicate in a multidimensional array

  28. 28

    Delete the duplicate words from array of strings in MySQL

  29. 29

    how to delete duplicate records from array of objects?

HotTag

Archive