⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frminstrumentation.cs

📁 清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Diagnostics;

namespace CodeForChapter4cs
{
  public partial class frmInstrumentation : Form
  {
    private void DoSomethingNew(object o)
    {
      ArrayList col = (ArrayList)o;
      int lastObject = col.Count - 1;
      int total = 0;
      for (int i = 0; i < lastObject; i++)
      {
        Debug.WriteLine(
          String.Format(
            "Iteration {0}:The 'total' is {1} and I will now add {2}", 
            i, 
            total, 
            ((MyType)col[i]).NoOfWidgets
          )
        );
        total += ((MyType)col[i]).NoOfWidgets;
      }

      MessageBox.Show("Total = " + total);
    }

    public frmInstrumentation()
    {
      InitializeComponent();
    }

    private void menuItem1_Click(object sender, EventArgs e)
    {
      ArrayList ar = new ArrayList(4);
      ar.Add(new MyType(1));
      ar.Add(new MyType(1));
      ar.Add(new MyType(2));
      ar.Add(new MyType(0));
      ar.Add(new MyType(1));
      this.DoSomething(ar);
    }

    private void DoSomething(object o)
    {
      ArrayList col = (ArrayList)o;
      int lastObject = col.Count - 1;
      int total = 0;
      for (int i = 0; i < lastObject; i++)
      {
         total += ((MyType)col[i]).NoOfWidgets;
      }

      MessageBox.Show("Total = " + total);
    }
  }

  public class MyType
  {
    public int NoOfWidgets;

    public MyType(int widgets)
    {
      NoOfWidgets = widgets;
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -