找回密碼
 註冊
搜索
查看: 9040|回復: 0

C# 建立全域變數及全域函式

[複製鏈接]
發表於 2007-7-9 15:28:20 | 顯示全部樓層 |閱讀模式
public struct basPublic
{
 public static string strTest;
 public static int intTest;

 public static string AppPath()
 {
  return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Substring(6);
 }
}

使用方法

private void frmMain_Load(object sender, EventArgs e)
{
 basPublic.strTest = "輸入文字";
 basPublic.intTest = 1000;
 MessageBox.Show(basPublic.AppPath());
}
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|彩色筆小沛的知識庫

GMT+8, 2024-5-3 04:00 , Processed in 0.016273 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回復 返回頂部 返回列表