----赖格英-----

记忆不好了,记录工作中的点点滴滴....

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.IO;

namespace NewTest
{
	public class PublicValue
	{
		public static string FileName;
		public static int[] aa;
	}
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		
		void MainFormLoad(object sender, EventArgs e)
		{
			this.Width=Screen.PrimaryScreen.WorkingArea.Width;
			this.Height =Screen.PrimaryScreen.WorkingArea.Height;
			this.Left =Screen.PrimaryScreen.WorkingArea.Left;			
			this.Top =Screen.PrimaryScreen.WorkingArea.Top;			
		}
		
		void Button1Click(object sender, EventArgs e)
		{			
			PublicValue.aa=new int[10];
			PublicValue.aa[0]=10;
			PublicValue.FileName="dfjlkjkldfsjl";
		}
	}
}

以上定义的publicValue类,其中的变量可以在同一个命名空间中使用,包括在子窗体或非子窗口中调用。

posted on 2016-12-01 20:25  向北方  阅读(40954)  评论(0编辑  收藏  举报