第一次做C/S的東西,遇見一個全局變量的問題.C/S中沒有Session,Application這樣的東西
上網查了知道原來是要設成一個靜态變量類,現把代碼列出來,以防遺忘
定義檔案:
using System;
using System.Collections.Generic;
using System.Text;
namespace spider_demo
{
public class BIANLIANG
{
private static string _url;
private static string _webinclude;
private static string _contentinclude;
private static string _type;
private static string _website;
public BIANLIANG(string x1,string x2 ,string x3,string x4,string x5)
{
_url = x1;
_webinclude = x2;
_contentinclude = x3;
_type = x4;
_website = x5;
}
public static string url
{
get
{
return _url;
}
}
public static string webinclude
{
get
{
return _webinclude;
}
}
public static string contentinclude
{
get
{
return _contentinclude;
}
}
public static string type
{
get
{
return _type;
}
}
public static string website
{
get
{
return _website;
}
}
}
}
寫入變量:
BIANLIANG xx = new BIANLIANG(url, webinclude, contentinclude,type,website);
讀出變量:
string aaaaaa=BIANLIANG.website.ToString();
轉載于:https://www.cnblogs.com/heigehao/archive/2011/11/14/2247893.html