我建了个类库项目,就一个类文件,代码如下:using System;
using System.Collections.Generic;
using System.Text;namespace topCat
{
public class Class1
{
int aaa = 0;
aaa=5;//类、结构或接口成员声明中的标记“=”无效 没有提示
}
}
生成 的时候出现
类、结构或接口成员声明中的标记“=”无效 没有提示
我输完 int aaa = 0;回车再输入 这个变量的时候 ,一般都会有快速提示列表的,但在提示列表里没有这个变量??求解!! 谢谢
using System.Collections.Generic;
using System.Text;namespace topCat
{
public class Class1
{
int aaa = 0;
aaa=5;//类、结构或接口成员声明中的标记“=”无效 没有提示
}
}
生成 的时候出现
类、结构或接口成员声明中的标记“=”无效 没有提示
我输完 int aaa = 0;回车再输入 这个变量的时候 ,一般都会有快速提示列表的,但在提示列表里没有这个变量??求解!! 谢谢
这样给值是错误,它只能在方法或者函数内给值,
在外面给值是错误的
public class Class1
{
int aaa = 0;
aaa=5;//类、结构或接口成员声明中的标记“=”无效 没有提示
}
改为public class Class1
{
int aaa = 0;
void set()
{
aaa =5;
}
}
public class Class1
{
int aaa=0;
封装后,在构造函数中赋值
}用2楼的也可以