| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1874 人关注过本帖
标题:请教!!!
取消只看楼主 加入收藏
ufo0303
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-1-22
收藏
 问题点数:0 回复次数:2 
请教!!!

using System; //引用System命名空间

public class MyCollection //创建一个类 MyCollection { int[] items;

public MyCollection() //这条语句是继承 MyCollection 类的么? { items = new int[5] {12, 44, 33, 2, 50}; 为什么不写成int items=new int[5]{12,44,33,2,50}呢?是整形变量的关键字可以省略的么? }

public MyEnumerator GetEnumerator() { return new MyEnumerator(this); //return在这里具体的意思是什么?请指教,谢谢!!! } public class MyEnumerator { int nIndex; MyCollection collection; //是类型的继承么? public MyEnumerator(MyCollection coll) //此类有什么意思,能解释下么?谢谢!!! { collection = coll; nIndex = -1; }

public bool MoveNext() //请解释,谢谢!!! { nIndex++; return(nIndex < collection.items.GetLength(0)); }

public int Current //请解释,谢谢!!! { get { return(collection.items[nIndex]); } } } }

public class MainClass { public static void Main() { MyCollection col = new MyCollection(); Console.WriteLine("Values in the collection are:");

// Display collection items: foreach (int i in col) { Console.WriteLine(i); } } }

搜索更多相关主题的帖子: 整形 public MyCollection int 变量 
2005-01-25 10:21
ufo0303
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-1-22
收藏
得分:0 
LIVE41 不好意思,又要麻烦你看下了,这是我在MSDN里COPY的,希望对语法有更具体的了解,谢谢你!!!
2005-01-25 10:24
ufo0303
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-1-22
收藏
得分:0 
顶一下polestar707提出的问题,我也有点不清楚,请指点!!!
2005-01-26 09:51
快速回复:请教!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012157 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved