Why can't I ask for this array's Length?

Ok, so I have code of this form:

int[] blob = new int[3];
int length = blob.Length;

however, MonoDevelop highlights Length in red and tells me that

“‘System.Int32’ does not contain a definition for Length”

Where am I going wrong?

Oh, and I’m using Unity 5.2 personal, pretty fresh install, no shenenigans on Windows 10

I assume that the two lines of code are both in the script’s main body; it doesn’t work that way. If you want to assign the Length value of blob to the variable length, then you have to do this in Awake, Start or somewhere else.

int[] blob = new int[3];
int length;

void Awake() {
     length = blob.Length;
}

If it’s only in MonoDevelop, that’s a bug that exists for a long time. I’m still not sure what triggers it but what basically happens is that MonoDevelops intellisense engine “sees” an array type not as array but like a normal variable. So when it tries to resolve the member info for Length it fails since it doesn’t see a “int” but an “int” and an integer variable doesn’t have a Length.

The intellisense engine of MonoDevelop is very “sensitive”. If there are any compiler errors somewhere it breaks almost completely or shows wrong information. It also can be confused easily with generic parameters or other “complex” structures.

I would suggest, if you’re on windows, to not use MonoDevelop at all and switch to VisualStudio. The express edition can’t be integrated as easy in Unity as MonoDevelop but it’s by far the best IDE when you write C# code.

If you want to stick with MonoDevelop you should simply ignore any error it marks for you. Save and Switch to Unity to actually see if there are errors. If there are errors in Unity, post those. The errors you see in Unity are the actual errors.