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 791963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:55:09+00:00 2026-05-14T21:55:09+00:00

In MonoDevelop I have the following code which compiles: int[] row = new int[indices.Count]{};

  • 0

In MonoDevelop I have the following code which compiles:

int[] row = new int[indices.Count]{};

However, at run-time, I get:

Matrix.cs(53,53): Error CS0150: A
constant value is expected (CS0150)
(testMatrix)

I know what this error means and forces me to then resize the array:

int[] row = new int[indices.Count]{};
Array.Resize(ref row, rowWidth);

Is this something I just have to deal with because I am using MonoDevelop on Linux? I was certain that under .Net 3.5 I was able to initialize an array with a variable containing the width of the array. Can anyone confirm that this is isolated? If so, I can report the bug to bugzilla.

  • 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-14T21:55:10+00:00Added an answer on May 14, 2026 at 9:55 pm

    You can’t mix array creation syntax with object initialization syntax. Remove the { }.

    When you write:

    int[] row = new int[indices.Count];
    

    You are creating a new array of size indices.Count initialized to default values.

    When you write:

    int[] row = new int[] { 1, 2, 3, 4 };
    

    You are creating an array and then initializing it’s content to the values [1,2,3,4]. The size of the array is inferred from the number of elements. It’s shorthand for:

    int[] row = new int[4];
    row[0] = 1;
    row[1] = 2;
    row[2] = 3;
    row[3] = 4;
    

    The array is still first initialized to defaults, this syntax just provides a shorthand to avoid havind to write those extra assignments yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the problem I just installed the new Monodevelop 2.2.2 on Windows but
I'm trying to run MonoDevelop on apple. I have instaled all the necessary SDK
When I run my iOS project in MonoDevelop through the simulator I get the
I'm on Ubuntu 11.10 , have installed Monodevelop-2.8.5 , on the first run, it
In MonoDevelop (Mac) I wish to have the code formatter-cleaner (Shift_Control_f) leave the line
In goofing around with some F# (via MonoDevelop), I have written a routine which
Somehow I managed to get MAC pc OS 10.5.3. I have installed mono, monodevelop
I have some code in objective-C which uses the 'mutableCopy' method to make a
I have monodevelop running great except for the fact that I need to get
I have a project set up in MonoDevelop, it compiles and runs fine for

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.