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

  • Home
  • SEARCH
  • 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 7580139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:50:30+00:00 2026-05-30T17:50:30+00:00

I am using C# asp.net in my project. I use 2d array in that.

  • 0

I am using C# asp.net in my project. I use 2d array in that. Named roomno. When I try to remove one row in that. So I Convert the array into list.

static string[,] roomno = new string[100, 14];
List<string>[,] lst = new List<string>[100, 14];



lst = roomno.Cast<string>[,]().ToList();

Error   1   Invalid expression term 'string' in this line...
if i try below code,
 lst = roomno.Cast<string>().ToList();

I got

Error   3   Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<string>[*,*]'

lst = roomno.Cast().ToList();

What is the Mistake in my code?.

After that, I plan to remove the row in list, lst.RemoveAt(array_qty);

  • 1 1 Answer
  • 0 Views
  • 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-30T17:50:31+00:00Added an answer on May 30, 2026 at 5:50 pm

    This:

    List<string>[,] lst = new List<string>[100, 14];
    

    is declaring a 2-D array of List<string> values.

    This:

    roomno.Cast<string>[,]().ToList();
    

    … simply doesn’t make sense due to the position of the [,] between the type argument and the () for the method invocation. If you changed it to:

    roomno.Cast<string[,]>().ToList();
    

    then it would be creating a List<string[,]> but it’s still not the same as a List<string>[,].

    Additionally, roomno is just a 2-D array of strings – which is actually a single sequence of strings as far as LINQ is concerned – so why are you trying to convert it into an essentially 3-dimensional type?

    It’s not clear what you’re trying to do or why you’re trying to do it, but hopefully this at least helps to explain why it’s not working…

    To be honest, I would try to avoid mixing 2-D arrays and lists within the same type. Would having another custom type help?

    EDIT: LINQ isn’t going to be much use with a 2-D array. It’s designed for single sequences really. I suspect you’ll need to do it “manually” – here’s a short but complete program as an example:

    using System;
    
    class Program
    {
        static void Main(string[] args)        
        {
            string[,] values = {
                {"x", "y", "z"},
                {"a", "b", "c"},
                {"0", "1", "2"}
            };
    
            values = RemoveRow(values, 1);
    
            for (int row = 0; row < values.GetLength(0); row++)
            {
                for (int column = 0; column < values.GetLength(1); column++)
                {
                    Console.Write(values[row, column]);
                }
                Console.WriteLine();
            }
        }
    
        private static string[,] RemoveRow(string[,] array, int row)
        {
            int rowCount = array.GetLength(0);
            int columnCount = array.GetLength(1);
            string[,] ret = new string[rowCount - 1, columnCount];
    
            Array.Copy(array, 0, ret, 0, row * columnCount);
            Array.Copy(array, (row + 1) * columnCount,
                       ret, row * columnCount, (rowCount - row - 1) * columnCount);
            return ret;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an ASP.NET project using MVP architecture. We would like to use
I use ASP.net Ajax on my project. and using Session for state management. in
I have an ASP.Net project using AJAX that I am putting on a server
I am using NHibernate on a new ASP.NET project, and am running into what
I have an existing ASP.Net MVC project that is using entities / repositories in
Currently I'm working on Web project that is built using ASP.NET Web Forms. We
I'm starting a project that will be public facing using asp.net mvc. I know
i have a project using ASP.Net MVC3 and using membership for roles. i use
In my ASP.Net project; I'm using C# as behind code. One of my project
I have a asp.net project that uses mvc-mini-profiler. I was using version 1.7 of

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.