5??C#??Java??????????
???????????? ???????[ 2012/6/12 14:36:40 ] ????????
????C????Java?????????????????δ????????????????????????????????????????????????????????????Щ???????в??????????????????????á?????Java?????????????????????C?????????????з?????????????????????????????????
????#1??Virtual ????
????C???????????????鷽??
????Java????????????鷽??
?????鷽???????κ????У?????д????????Java?У????з?????????鷽????????????÷???????????????????????????????
??????C???У??????????????????????virtual?????????鷽????
1.public class Dimensions
2.{
3. public const double pi = Math.PI;
4. protected double x?? y;
5. public Dimensions()
6. {
7. }
8. public Dimensions (double x?? double y)
9. {
10. this.x = x;
11. this.y = y;
12. }
13.14. public virtual double Area()
15. {
16. return x*y;
17. }
18.}
??????????????鷽?????÷???????????override????????
1.public class Circle: Dimensions
2.{
3. public Circle(double r): base(r?? 0)
4. {
5. }
6.7. public override double Area()
8. {
9. return pi * x * x;
10. }
11.}
????#2??Generator ????
????C#?????generator????
????Java???????generator????
????generator???????????????????????????????ε??????????????????飬generator??????????ε?????????????????????Java??????????generator????????????????Java??????Щ????????????????????????C#??á?IEnumerable????????generator???????yield???????????
1.public class TexasCityCollection : IEnumerable<string> {
2. public IEnumerator<string> GetEnumerator() {
3. yield return "Houston";
4. yield return "Auston";
5. yield return "Dallas";
6. yield return "San Antonio";
7. }
8.}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11