This question got closed. Initial close comment:

I'm voting to close this question as off-topic because it's asking for a feature request, not for a Code Review.

3 counts on that and 2 for broken code/code not written. In chat it turned out one of them hit the wrong button and the other had a slightly different opinion on what we call 'code not written yet'.

While we all agreed it wasn't a good question but we didn't agree whether it was within scope.

In my opinion, it's asking a very specific question. It wasn't asking for a review, it was asking an alternative for a small piece of the code. When in doubt, I take this table and the on-topic help center as guideline as to what 'type' of questions are on-topic.


OP doesn't. OP wants a specific piece rewritten in a particular way.

I think this comment summed it up:

I think you're looking for a very specific alternative. You can either ask for a full review on the current code, in which case we need context. Or you can go with a specific question to Stack Overflow and use the current code as proof of prior research.

Should we consider such questions on-topic or not?

  • 4
    \$\begingroup\$ For the record, the question is asking: Is it possible to remove the inner loop by assigning data.Data.Tables[0].Rows[i].ItemArray directly? \$\endgroup\$ – Simon Forsberg Sep 7 '15 at 10:13

I have voted to leave the question closed. I disagree with the close reasons though, "asking for a feature" and the alternative that it "does not work". I believe the code could work, and that the "feature request" could be overlooked and the code reviewed anyway. My real issue is that there's no context, and the code looks hypothetical, and stripped of any context. Let's look:

object[,] arr = new object[52784, 21];

for (int i = 0; i < data.Data.Tables[0].Rows.Count; i++)
    for (int j = 0; j < data.Data.Tables[0].Columns.Count; j++)
      arr[i, j] = data.Data.Tables[0].Rows[i][j];

Why those sizes on the arr? What's special with 52784, and 21?

Why the specific names data.Data.Tables, and what's special with table 0?

There is absolutely nothing in the question that gives any context for anything.

A 'valid' answer could just be: Initialize the arr with constant values: object[,] arr = { {...}, {...}, .....};

I would vote to close as either "hypothetical code", or "unclear what you're asking".


This question is on topic in my opinion and I've voted to reopen it.

  • It's OP's code.
  • Even without context, it's a pretty clear question.
  • The code isn't broken.
  • OP isn't asking for new functionality, but for a better way to do the same thing. (i.e. not a feature request).


This sounds like a "How do I?" question, and it's possible that this is one of those rare CR questions that would also be on topic for StackOverflow, but let's read between the lines a little bit. OP has an idea of how to make his code better, but not how to do it. I don't think that's off topic for a couple of reason.

  1. I've seen questions that contain broken code (in addition to ugly, working code) of the form

    • Here's my code. It's bad.
    • I tried this to fix it, but it didn't work.
    • Can anyone help?

    If those kinds of questions are on topic, surely making a suggestion about how I think it could be done better, but that I'm unsure about/don't know how to implement are as well.

  2. OP's suggestion could be the completely wrong approach and you're free to ignore their suggestion entirely and offer any advice what so ever that you feel would improve the code.

I'm kind of irked that I'm even writing this answer right now. I'm trying to defend an on topic question with no clue why this was put on hold to begin with. It's not the best quality question I've seen here, but it's on topic.


I think the question is still off-topic, because the OP hasn't included the actual code-of-issue:



The reason why I need this code is because, I want to write to data of this dataTable to Excel using Interop which requires a 2-D array as input.

Now, he indicates that this is not the actual issue, but that the actual issue is the Excel Interop he is doing, which is not actually included in the question.

This is a significant lack of context. We don't actually know how he is interacting with the Excel Interop. Knowing that may provide a better answer to the underlying question.

Personally, I think without that context this code is stub code.

  • \$\begingroup\$ This is an indication of a so-called "XY-problem". If XY-problems are off-topic, both Stack Overflow and Code Review can say good night. Vote to close as "hypothetical code" or "unclear what you are asking" if you prefer that. \$\endgroup\$ – Simon Forsberg Sep 8 '15 at 14:56

I voted to close this as off topic. My reasoning was to do with what was posted in the question


This is all the explanation/question they offered. That sounded to me like they only wanted to answer that one particular question, not get a review of their code. But also, the code they were asking about was code that wasn't written. They showed code they had written but then asked "Is it possible to do something else?"

Closing isn't about removing or deleting the question, it's about stopping it so that it can be potentially be improved to a fitting question rather than an ill fitting one. The question could be edited to possibly add code, but more importantly make the OP's intentions more clear if they really did want a review and not just a solution to a problem they asked about.

  • 2
    \$\begingroup\$ it's not really "Is it possible to do something else?" in my opinion, it is "Is it possible to do the same thing in this way instead?". The problem has already been solved, now the OP wanted to know if it could be solved differently. \$\endgroup\$ – Simon Forsberg Sep 7 '15 at 11:02
  • \$\begingroup\$ @SimonForsberg Does that mean the "Code not written" rule is to prevent people asking about something they haven't done at all, rather than asking about any code that doesn't exist? \$\endgroup\$ – SuperBiasedMan Sep 7 '15 at 11:09
  • \$\begingroup\$ @SimonForsberg That's not what is in the question though. We can not attempt any mind reading on what OP means, we're not qualified IMHO. \$\endgroup\$ – Mast Sep 7 '15 at 11:10
  • 2
    \$\begingroup\$ @SuperBiasedMan the "code not yet written" rule is there to prevent "gimme teh codez plz" and design only questions where nothing at all has been implemented. \$\endgroup\$ – RubberDuck Sep 7 '15 at 11:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .