
Define an abstract class named Poly
1: public abstract class Poly
2: {3: private int r = 0;
4: public int R
5: { 6: get 7: {8: return r;
9: } 10: set 11: {12: r = value;
13: } 14: }15: public abstract double Area();
16: }
1: public abstract class Poly
2: {3: private int r = 0;
4: public int R
5: { 6: get 7: {8: return r;
9: } 10: set 11: {12: r = value;
13: } 14: }15: public abstract double Area();
16: }

1: class test
2: {3: public override string ToString()
4: {5: return "c# 真好用";
6: } 7: }1: private void button1_Click(object sender, EventArgs e)
2: {3: using (FileStream fs = new FileStream(@"c:\log.txt",System.IO.FileMode.Create))
4: {5: object obj = fs as object;
6: if (obj != null)
7: {8: MessageBox.Show("轉換為Object成功!", "提示!");
9: }10: else
11: {12: MessageBox.Show("轉換為Object不成功!", "提示!");
13: }14: Stream strm = obj as Stream;
15: if (strm != null)
16: {17: MessageBox.Show("轉換為Stream成功!", "提示!");
18: }19: else
20: {21: MessageBox.Show("轉換為Stream不成功!", "提示!");
22: }23: string str = obj as string;
24: if (str != null)
25: {26: MessageBox.Show("轉換為string成功!", "提示!");
27: }28: else
29: {30: MessageBox.Show("轉換為string不成功!", "提示!");
31: } 32: 33: StreamReader f = obj as StreamReader;
34: if (str != null)
35: {36: MessageBox.Show("轉換為StreamReader成功!", "提示!");
37: }38: else
39: {40: MessageBox.Show("轉換為StreamReader不成功!", "提示!");
41: } 42: 43: }44: }


1: using System;
2: using System.Collections.Generic;
3: using System.ComponentModel;
4: using System.Data;
5: using System.Drawing;
6: using System.Linq;
7: using System.Text;
8: using System.Windows.Forms;
9: using System;
10: using System.Runtime.InteropServices;
11: 12: namespace HideTaskBarEx
13: { 14: 15: public partial class Form1 : Form
16: {17: [DllImport("user32.dll")]
18: private static extern IntPtr FindWindow(String className, String windowText);
19: [DllImport("user32.dll")]
20: private static extern Int32 ShowWindow(IntPtr hwnd, Int32 command);
21: private const Int32 HIDE = 0;
22: private const Int32 SHOW = 1;
23: public Form1()
24: { 25: InitializeComponent(); 26: } 27: 28: private void button1_Click(object sender, EventArgs e)
29: {30: IntPtr TaskBar = FindWindow("Shell_TrayWnd", "");
31: ShowWindow(TaskBar, HIDE); 32: } 33: 34: private void button2_Click(object sender, System.EventArgs e)
35: {36: IntPtr TaskBar = FindWindow("Shell_TrayWnd", "");
37: ShowWindow(TaskBar, SHOW); 38: } 39: } 40: }
1: public partial class Form1 : Form
2: { 3: NotifyIcon notifyIcon; 4: 5: private void Initial()
6: {7: notifyIcon = new NotifyIcon();
8: notifyIcon.BalloonTipText = "Program is Running..."; //設定通知欄提示的文字
9: notifyIcon.Text = "NotifyIcon Sample"; //設定通知欄在滑鼠移至Icon上的要顯示的文字
10: notifyIcon.Icon = (System.Drawing.Icon)Properties.Resources.forms; //決定一個Logo
11: notifyIcon.Click += (sender, e) => //設定按下Icon的事件
12: {13: notifyIcon.Visible = false;
14: this.ShowInTaskbar = true;
15: this.Show();
16: }; 17: 18: //設定右鍵選單
19: ContextMenu contextMenu = new ContextMenu();
20: MenuItem menuItem = new MenuItem();
21: menuItem.Checked = true;
22: menuItem.Index = 1;23: menuItem.Text = "顯示";
24: menuItem.Click += (sender, e) => //設定按下事件
25: {26: MessageBox.Show("開始...");
27: }; 28: contextMenu.MenuItems.Add(menuItem); 29: notifyIcon.ContextMenu = contextMenu; 30: }31: public Form1()
32: { 33: InitializeComponent(); 34: Initial(); 35: } 36: 37: private void button1_Click(object sender, EventArgs e)
38: {39: this.ShowInTaskbar = false;
40: this.Hide();
41: notifyIcon.Visible = true;
42: notifyIcon.ShowBalloonTip(1, "測試", "測試內容", ToolTipIcon.Info);
43: }44: }

1: private void button1_Click(object sender, EventArgs e)
2: { 3: listBox1.Items.Clear();4: foreach (var screen in Screen.AllScreens)
5: {6: listBox1.Items.Add("Device nAME: " + screen.DeviceName);
7: listBox1.Items.Add("Bounds: " + screen.Bounds.ToString());
8: listBox1.Items.Add("Type: " + screen.GetType().ToString());
9: listBox1.Items.Add("Working Area: " + screen.WorkingArea.ToString());
10: listBox1.Items.Add("Primary Screen: " + screen.Primary.ToString());
11: listBox1.Items.Add("=================================================");
12: } 13: }
