using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Bindings
{
public partial class Form1 : Form
{
data d1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
d1=new data ();
this.label1.DataBindings.Add("Text", d1, "Text");
this.textBox1.DataBindings.Add("Text", d1, "Text");
}
private void button1_Click(object sender, EventArgs e)
{
d1.Text = "this is a test!";
}
}
public class data
{
private string text;
public string Text
{
get
{
return this.text;
}
set
{
this.text = value;
}
}
public data()
{
this.text = "";
}
}
}
8 float 轉 int 時,會不會四捨五入?
static void Main(string[] args)
{
float f = -123.567F;
int i = (int)f;
//i =-123
}
9 ToString 參數影響的結果。
{
double a;
a = 1222.05;
Console.Write(a.ToString("# ")); //1222
Console.Write(a.ToString("## ")); //1222
Console.Write(a.ToString("##.# ")); //1222.1
Console.Write(a.ToString("##.## ")); //1222.05
Console.Write(a.ToString("####.### ")); //1222.05
Console.Write(a.ToString("####.###### ")); //1222.05
Console.Write(a.ToString("#############.######## ")); //1222.05
Console.Write(a.ToString("##.0 ")); //1222.1
Console.Write(a.ToString("(##)##.0 ")); //(12)22.1
string s=Console.ReadLine();
}