c#中的问题很恼火,请教
来源:百度知道 编辑:UC知道 时间:2024/06/09 00:38:31
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
}
}
public class customer
{
private string name;
private decimal balance;
public string customerName;
{
get{return name;}
set{name=value;}
//每到这里就在{下出现~并说在类,结构接口成员声明中的标记“{”无效,并且在输入get和set 对象成员列表中没有显示出get和set关键字,并且set下还显示命名空间并不着界包含诸如字段或方法之类的成员,这究竟怎么回事呢?
}
}
}
}
}
修改正确!
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
}
public class customer
{
private string name;
private decimal balance;
public string customerName
{
get
{
return name;
}
set
{
name = value;
}
}
}
}
}
错误原因:public string customerName;
多了一个;号!
后面多两个大括号‘‘‘
1. 属性 customerName 后边不应该有分号
2. 最后两个“}” 是多余的。
看来你有必要给你vs加装两个插件
一个Visual.Assist,代码提示插件
coderush 代码提示,代码简写及括号匹配和帮助你检查{}匹配和if匹配的彩色连线
不过加装插件以后vs在加载