The fourth chapter realizes the data update of Windows program. Enumeration 1. What is an enumeration?
A set of descriptive names.
2. Why use enumerations?
Let's say we're writing sex.
int gender = 0;//0 on behalf of male
= 1;//1 on behalf of women
= 2;
= 3;
How do I use enumerations?
public enum Gender
{
Male,fmale
}
Gender.male;
Gender.fmale;
public class Student
{
private int age;
public int Age
{
Get{return This.age;}
Set{this.age=value;}
}
private string name;
public string Name
{
Get{return THIS.name;}
Set{this.name = value;}
}
Private Gender Gender;//Field
Public Gender gender//Property
{
Get{return This.gender;}
Set{this.gender=value}
}
public void Show ()
{
string s = String.Empty ();
if (this. gender.tostring () = = "Male")
{
s = "male";
}
Else
{
s = "female";
}
Console.WriteLine (this. Age+ "--" + this. Name + "--" + s);
}
}
public static void Main (string[] args)
{
Student stu = new Student ();
Stu. Age = 10;
Stu. Name = "Xiao Qiang";
Use of enumerations
Stu. Gender = Gender.male;
}
Where do you use enumerations?
Sex, Grade
public enum Grade
{
S1,s2,y2
}
3. Timers Timer
When the WinForm form loads, the time is displayed.
A.enable:true
b.inteval:1000, how long is the first time
C.time1_tick (Object Obj,eventargs s)//How often to invoke the method
Be a child and turn the book.
1). ImageList
2). PictureBox take a picture from the ImageList
3). Use the timer to realize the effect of changing pictures
Fourth. Implementing data Updates for Windows programs