- Home /
The question is answered, right answer was accepted
CS0266 cannot convert type 'object' (which actually is a argument of type int[,]) to 'int[,]'
Hello everyone! i've got a bit of a struggle with the following function:
int[,] SmoothMap(int[,] map, int amount){
int[,] TempMap = map.Clone ();
for (int StupidVar=0; StupidVar<amount; StupidVar++){
for (int x = 0; x < LevelSize; x++) {
for (int y = 0; x < LevelSize; y++){
Delidding(map, x, y);
}
}
}
return TempMap;
}
Unity throws out the error for line 2
error CS0266: Cannot implicitly convert type `object' to `int[,]'. An explicit conversion exists (are you missing a cast?)
It thinks that the argument is not off type int['], but of type 'object'. How can i fix this?
Answer by Roeffus · Aug 12, 2016 at 03:27 PM
Solved!
int[,] TempMap = (int[,])map.Clone ();
Fixed it. This tells the compiler map will be off type int[,] which is a bit weird, because map is already declared as int[,] (and yes i have to say that, because it annoys me).
Follow this Question
Related Questions
Convert localScale to float? 1 Answer
What is wrong with my C# script? 2 Answers
Video Workaround in Unity 1 Answer
Cant convert int to string in c# 1 Answer
cannot convert UnityEngine.Gameobject to GameObject - What's the difference? 1 Answer