Said: The purpose of the sweeping monk practicing peerless martial arts is to sweep the floor cleaner.
1 text format
/// <summary>
/// Lesson 1 of "Xiaobai Learning Programs": Getting to Know Programs
/// </summary>
/// <param name="sender"></param>
/// <param name ="e"></param>
private void button1_Click(object sender, EventArgs e)
{ // #1 variable // define some names for storing data ----- variable Variable float a = 10; int b = 20 ; int d = 300; float z = 30.5f; // basic four arithmetic operations float c = a / b + d * z; // mathematical calculations and mathematical constants (such as pi, written as Math.PI) double h = Math .Sin(30.0 * Math.PI / 180.0);
// #2 Preliminary contact with variables
// float and double are used to store floating point numbers (real numbers);
// int is used to store integers;
// float constants need to be followed by f or F
// #3 output
// The following is a "commented" line, indicating that this line does not participate in execution;
// webBrowser1.DocumentText = c + " = " + a + " / " + b + " + " + d + " * " + z ;
// Improved, you can change the font size and color output;
webBrowser1.DocumentText =
"<font style='font-size:22px;'>" + c +
"</font> = <font color=red>" + a +
"</font> / <font color=blue>" + b +
"</font> + <font color=purple>" + d +
"</font> * <font color=orange>" + z +
" </font>";
}
2 code format
/// <summary>
/// 《小白学程序》第一课:初识程序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
// #1 变量
// 定义一些用于存储数据的名称————变量Variable
float a = 10;
int b = 20;
int d = 300;
float z = 30.5f;
// 基本的四则运算
float c = a / b + d * z;
// 数学计算与数学常数(比如圆周率 π,写作Math.PI)
double h = Math.Sin(30.0 * Math.PI / 180.0);
// #2 关于变量的初步接触
// float 与 double 用于存储 浮点数(实数);
// int 用于存储整数;
// float 的常数后面需要加个 f 或 F
// #3 输出
// 下面这样是 被“注释”的行,说明本行不参与执行;
// webBrowser1.DocumentText = c + " = " + a + " / " + b + " + " + d + " * " + z;
// 改进,可以改变 字体大小 与 颜色 的输出;
webBrowser1.DocumentText =
"<font style='font-size:22px;'>" + c +
"</font> = <font color=red>" + a +
"</font> / <font color=blue>" + b +
"</font> + <font color=purple>" + d +
"</font> * <font color=orange>" + z +
"</font>";
}
Everyone did not learn programming well because there is no good programming textbook in the world.