C#总结(四)

修饰方法的参数

 out,在方法外面可以不给这个参数赋值,但是在方法里面必须给这个out修饰符的参数赋初值。另外,参数加out,是把这个方法中的参数的值传到方法外面去了。

这里写图片描述

 ref,这个用的时候必须要给这个变量赋初值,和out有区别,out可以把方法里的值传出去,ref可以把值传到方法里,又可以把值传到方法外。

这里写图片描述

面向对象

 对象特指的具体点的,看得到摸得着。
 属性—对象的各种特征。每个对象的每个属性都拥有特定值。

这里写图片描述

 抽象出来的模板,确定对象将拥有的特征(属性)和行为(方法)。
 类不占内存,对象才占内存。
 类中可以包含变量的定义、方法。
[访问修饰符/ public] class 类名
{
成员;
......
}
 类的实例化 类的实例化用关键字new;
 语法: 类 +实例名=new+类();
 类的成员访问:语法:实例名.属性 / 实例名.方法名()
 字段用public修饰的问题…用private
 属性的定义:get;set;
 属性是为了保护与之相对应的字段的,保证对字段的读取和赋值符合要求。
 属性可分为:读写、只读、只写。
 允许外部访问的变量一定要声明为属性。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
public void Polygon_Trans4(IFeatureClass pFeatureCls, string strPath, string strFilename, ProgressBar pBar) { if (pFeatureCls == null || strPath == "" || strFilename == "") return; createNewShape(strPath, strFilename, pFeatureCls); IFeatureCursor pFeatCursor = pFeatureCls.Search(null, false); IFeature pFeature = pFeatCursor.NextFeature(); //打开目标图层 IWorkspaceFactory pWSF = new ShapefileWorkspaceFactoryClass(); IWorkspace pWS = pWSF.OpenFromFile(strPath, 0); IFeatureWorkspace pFWS = (IFeatureWorkspace)pWS; IFeatureClass pTargetFClass = pFWS.OpenFeatureClass(strFilename); IWorkspaceEdit pWSEdit = pWS as IWorkspaceEdit; pWSEdit.StartEditOperation(); pWSEdit.StartEditing(false); ITable pTble = (ITable)pFeatureCls; int lCunt = pTble.RowCount(null); pBar.Visible = true; pBar.Minimum = 0; pBar.Maximum = lCunt; pBar.Step = 1; IFeature pNewFeature; IPolygon pOutPolygon; IGeometryCollection pOutGeos; IPolygon pInPolygon; IGeometryCollection pInGeos; IPoint pOutPnt = new PointClass(); IPointCollection pOutPnts; while (pFeature != null) { pBar.PerformStep(); pNewFeature = pTargetFClass.CreateFeature(); pOutPolygon = new PolygonClass(); pOutGeos = pOutPolygon as IGeometryCollection; //获取原图形 pInPolygon = pFeature.Shape as IPolygon; pInGeos = pInPolygon as IGeometryCollection; for (int m = 0; m < pInGeos.GeometryCount; m++) { IGeometry pInGeo = pInGeos.get_Geometry(m); IPointCollection pInPnts = pInGeo as IPointCollection; pOutPnts = new PolygonClass(); object missing = Type.Missing; for (int n = 0; n < pInPnts.PointCount; n++) { IPoint pInPnt = pInPnts.get_Point(n); //转换点坐标 pOutPnt.X = ClsParas4.m_OffY + pInPnt.Y * ClsParas4.m_vb + pInPnt.X * ClsParas4.m_va; pOutPnt.Y = ClsParas4.m_OffX + pInPnt.Y * ClsParas4.m_va - pInPnt.X * ClsParas4.m_vb; pOutPnts.AddPoint(pOutPnt, ref missing, ref missing); } ISegmentCollection pSegmentCols = new RingClass(); pSegmentCols.AddSegmentCollection(pOutPnts as ISegmentCollection); pOutGeos.AddGeometry(pSegmentCols as IGeometry, ref missing, ref missing); } for (int i = 0; i < pFeature.Fields.FieldCount; i++) { if (pNewFeature.Fields.get_Field(i).Name.ToString().Equals("FID", StringComparison.CurrentCultureIgnoreCase) || pNewFeature.Fields.get_Field(i).Name.ToString().Equals("SHAPE", StringComparison.CurrentCultureIgnoreCase)) continue; pNewFeature.set_Value(i, pFeature.get_Value(i)); } pNewFeature.Shape = pOutPolygon as IGeometry; pNewFeature.Store(); pFeature = pFeatCursor.NextFeature(); } pBar.Visible = false; pWSEdit.StopEditOperation(); pWSEdit.StopEditing(true); }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值