[英]Creating an instance of an object with a char[] property
I have a class with an char[] property, but when I try to create an instance of it I get an error. 我有一个带有char []属性的类,但是当我尝试创建它的实例时,出现错误。 My code is this:
我的代码是这样的:
Class: 类:
public class Board
{
private char[] priFC;
public Board(char[] priFC){
this.priFC = priFC;
}
...}
Main: 主要:
Board Tab = new Board(char[10]);
I get an invalid expression term char at the creation of Tab 我在创建Tab时收到无效的表达式术语char
In Main, while creating instance of Tablero
pass instance of char[]
, instead of char[10]
something like 在Main中,在创建
Tablero
实例时传递char[]
实例,而不是char[10]
,例如
Tablero Tab = new Tablero(new []{'s','t','a','c','k','o','v','e','r','f','l','o','w'});
or 要么
Tablero Tab = new Tablero(new char[10]);
or 要么
char [] charInstance = new char[]{'s','t','a','c','k','o','v','e','r','f','l','o','w'};
Tablero Tab = new Tablero(charInstance);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.