C# GIS开发中:“错误 应输入 class、delegate、enum、interface 或 struct ”如何解决?

private void autoLabel(string layerName)
{
MapXLib.Layer layer=axMap1.Layers._Item(layerName);
MapXLib.Dataset ds=axMap1.DataSets._Item("ds"+layerName);
layer.LabelProperties.Dataset =ds;
layer.LabelProperties.DataField =ds.Fields._Item("name");
layer.LabelProperties.Position=MapXLib.PositionConstants.miPositionBC;
layer.LabelProperties.Style.TextFont.Size=10;
layer.LabelProperties.Offset=4;
layer.AutoLabel =true;
}

错误 1 应输入 class、delegate、enum、interface 或 struct D:\GIS开发与应用\示例程序\C#\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs 43 9 WindowsFormsApplication2

第1个回答  2012-10-14
你少写代码了,你代码内容肯定出错了,比如函数写在类之外。等等..
第2个回答  2012-10-14
你确定这代码是写在某个类的"{}"花括号里? 第43行的代码是啥?追问

你好,这是我从教材上拷贝下来的代码,我没有写在任何类的"{}"中

提示问题出在“ private void autoLabel(string layerName)"这一行,void被标注红色波浪线,提示如上问题,

追答

你这段代码是在哪个类下面?比如

private class Test
{
private void autoLabel(string layerName)
{
}
}
这样才行!

private class Test
{
}
private void autoLabel(string layerName){}
这样就会出现你所遇见的错误!

本回答被提问者采纳
相似回答
大家正在搜