【在线等】c#命名空间不能直接包含字段或方法之类的成员
<?xml version="1.0" encoding="utf-8"?><Database Name="HP" Class="DataClasses1DataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007"><Connection Mode="AppSettings" ConnectionString="Data Source=.\\sqlexpress;AttachDbFilename=|DataDirectory|\\HP.MDF;Integrated Security=True" SettingsObjectName="SelecttDoctor.Properties.Settings" SettingsPropertyName="HPConnectionString3" Provider="System.Data.SqlClient" />
<Table Name="dbo.DoctorInfo" Member="DoctorInfo">
<Type Name="DoctorInfo">
<Column Name="DoctorID" Type="System.String" DbType="Char(5) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Column Name="DoctorName" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
</Type>
</Table>
<Table Name="dbo.SelectInfo" Member="SelectInfo">
<Type Name="SelectInfo">
<Column Name="DoctorID" Type="System.String" DbType="Char(5) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Column Name="PatientID" Type="System.String" DbType="Char(5) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Column Name="SelectTime" Type="System.TimeSpan" DbType="Time" CanBeNull="true" />
</Type>
</Table>
<Table Name="dbo.PatientInfo" Member="PatientInfo">
<Type Name="PatientInfo">
<Column Name="PatientID" Type="System.String" DbType="Char(5) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Column Name="PatientName" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
</Type>
</Table>
</Database>
如上,求高手啊 --------------------编程问答-------------------- 什么意思?你这个不是c#源文件而是xml文件? --------------------编程问答-------------------- 回复2楼:我不能不清楚啊,是用VS2010打开的,后缀是.dbml,而且貌似也不容易看到
--------------------编程问答-------------------- 你一定是把什么代码写在类外面了,比如
namespace xxx
{
private int xxx; //error 字段
public void foo() //或者方法,都不能放在class的外面,直接位于namespace里面
{
...
}
class xxx
{
...
}
} --------------------编程问答-------------------- 回复3楼:
好深奥,有没有好理解的说法,我是新手 --------------------编程问答-------------------- 两点:
1、你出问题的代码应该不是你所发上来的代码,在vs中双击错误提示会定位到你出错的文件
2、定位到错误文件后你看下,应该存在3楼caozhy版主所说的情况,就是指定了命名空间就直接写属性或方法了,而实际他们的包含关系是命名空间-类-属性或方法
补充:.NET技术 , C#