Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1097707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:28:19+00:00 2026-05-17T00:28:19+00:00

I have a database that deconstructs an x,y coordinate pair table into specific dataitems.

  • 0

I have a database that deconstructs an x,y coordinate pair table into specific dataitems.

Coordinate
{
   int X,
   int Y,
   int Value
}

How do I rejoin these coordinates in Linq into a table? What if there are empty spaces in the Database (denoted by -):

             Y
          0  1  2
          -------
    0  |  4  6  7
 X  1  |  9  -  7
    2  |  6  3  5

How do I handle that in linq?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:28:19+00:00Added an answer on May 17, 2026 at 12:28 am

    LINQ is generally good for working with structured (one-dimensional) data such as databases or XML files, but I don’t think it will help you when you need to create two-dimensional data structure.

    If you just want to load the data into a 2D array, than it probably cannot get much nicer than the direct way of writing it (using Max extension method from LINQ to get the size):

    int[,] values =  
      new int[coords.Max(c => c.X) + 1, coords.Max(c => c.Y) + 1];
    foreach(var c in coords) 
      values[c.X, c.Y] = c.Value;
    

    If you want to do it the other way round – to generate coordinates from a 2D array, then you can use LINQ’s Enumerable.Range to generate indices of the 2D array and where to select elements that contain some actual value:

    var coords = from i in Enumerable.Range(0, coords.GetLength(0))
                 from j in Enumerable.Range(0, coords.GetLength(1))
                 let v = coords[i, j]
                 where v != '-'
                 select new { X = i, Y = j, Value = Int32.Parse(v) }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database that contains a two tables, where these table have a
i have DataBase function that calculate distance by coordinates CREATE OR REPLACE FUNCTION distance(lat1
I have a database that had 15 years of cruft stuffed into it by
I have a database that has a table email_eml that stores 3 attributes name_eml,
I have a database that has a Users table and I present the data
I Have Database that contains 4 tables TABLE TBLCARTITEM (CART_ID, ITEM_ID, PROMOTION_ID, many more
I have a database that keeps track of books. The books table looks like
I have a database that stores a large number of codes, these codes are
I have a database that had data parsed into it. During parseing ampersands and
I have a database that shares columns for relationships. Here is the condensed table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.