📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace indexers
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.TextBox txNum;
private System.Windows.Forms.ListBox lsBits;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txNum = new System.Windows.Forms.TextBox();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.lsBits = new System.Windows.Forms.ListBox();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.SuspendLayout();
//
// txNum
//
this.txNum.Location = new System.Drawing.Point(80, 32);
this.txNum.Name = "txNum";
this.txNum.Size = new System.Drawing.Size(96, 20);
this.txNum.TabIndex = 0;
this.txNum.Text = "12345";
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(96, 72);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(48, 20);
this.numericUpDown1.TabIndex = 2;
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// lsBits
//
this.lsBits.Location = new System.Drawing.Point(96, 120);
this.lsBits.Name = "lsBits";
this.lsBits.Size = new System.Drawing.Size(72, 108);
this.lsBits.TabIndex = 3;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(256, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lsBits,
this.numericUpDown1,
this.txNum});
this.Name = "Form1";
this.Text = "Indexer demo";
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void numericUpDown1_ValueChanged(object sender, System.EventArgs e) {
//get the index value from the updown control
int index = Convert.ToInt32 (numericUpDown1.Value );
//create an instance of the BitList class
BitList bits = new BitList(txNum.Text );
//get that bit value using the indexer
int bit = bits[index];
//add it to the list box
lsBits.Items.Add (Convert.ToString (bit));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -