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

📄 form1.cs

📁 这是.net2005学习不可缺少的教程
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Generics
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void RegularClick(object sender, EventArgs e)
        {
            // Define the number of values to add and remove
            int iterations = 10000000; // 10,000,000

            // Create an instance of RegularStack and initialise it
            RegularStack s = new RegularStack(iterations);

            // Note the start time
            DateTime start = DateTime.Now;
            // Push the values onto the stack
            for (int f = 0; f < iterations; ++f)
                s.Push(f);

            // Pop the values off the stack
            for (int f = 0; f < iterations; ++f)
                s.Pop();

            // Compute the time taken to complete the test
            float ticks = DateTime.Now.Ticks - start.Ticks;
            float duration = ticks / TimeSpan.TicksPerSecond;

            // Display the duration to the user
            MessageBox.Show("Duration = "
               + String.Format("{0:#0.0000}", duration));
        }

        private void GenericClick(object sender, EventArgs e)
        {
            // Define the number of values to add and remove
            int iterations = 10000000; // 10,000,000

            // Create an instance of GenericStack and initialise it
            GenericStack<int> s = new GenericStack<int>(iterations);

            // Note the start time
            DateTime start = DateTime.Now;
            // Push the values onto the stack
            for (int f = 0; f < iterations; ++f)
                s.Push(f);

            // Pop the values off the stack
            for (int f = 0; f < iterations; ++f)
                s.Pop();

            // Compute the time taken to complete the test
            float ticks = DateTime.Now.Ticks - start.Ticks;
            float duration = ticks / TimeSpan.TicksPerSecond;

            // Display the duration to the user
            MessageBox.Show("Duration = "
               + String.Format("{0:#0.0000}", duration));
        }
    }
}

⌨️ 快捷键说明

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