InvalidCastException: Cannot cast from source type to destination type.

The specific error :
InvalidCastException: Cannot cast from source type to destination type.
Game.StartPlaceTiles (Int32 tiles, Int32 blackTiles, UnityEngine.GameObject whiteTile, UnityEngine.GameObject blackTile) (at Assets/Scripts/Game.cs:25)
Game.Start () (at Assets/Scripts/Game.cs:12)

I get this error from this c# script:

public class Game : MonoBehaviour {
	GameSettings settings = new GameSettings();
	public GameObject whiteTile;
	public GameObject blackTile;

	void Start() 
	{
		StartPlaceTiles (settings.Tiles, settings.BlackTiles, whiteTile, blackTile);
	}
	
	void StartPlaceTiles(int tiles,int blackTiles,GameObject whiteTile,GameObject blackTile)
	{
		for (int i = 0; i < 8; i++) 
		{
			string row = GameExtension.RandomGeneration (tiles, blackTiles);
			char[] arrch  = new char[tiles];
			arrch =row.ToCharArray();
			for(int j = 0;j < tiles;j++)
			{
				int k = 1;
				int tileToPlace = (int) arrch.GetValue(k);
				if (tileToPlace == 0)
					Instantiate(whiteTile,new Vector3(k-((tiles-1)/2),i*2+6,0),Quaternion.identity);
				else
					Instantiate(blackTile,new Vector3(k-((tiles-1)/2),i*2+6,0),Quaternion.identity);
				k++;
			}
		}
	}
}

Bit of a weird one that, for some reason the return value of GetValue() isn’t able to be cast explicitly, even though it is coming back as System.Char which should be fine to cast in this case. In any case, try using array access operators:

int tileToPlace = (int)arrch[k];

Or System.Convert:

int tileToPlace = System.Convert.ToInt32(arrch.GetValue(k));

Both these worked for me.