C#中控制遠(yuǎn)程計(jì)算機(jī)的服務(wù)的方法
更新時(shí)間:2007年04月16日 00:00:00 作者:
在.net中提供了一些類來顯示和控制Windows系統(tǒng)上的服務(wù),并可以實(shí)現(xiàn)對(duì)遠(yuǎn)程計(jì)算機(jī)服務(wù)服務(wù)的訪問,如System.ServiceProcess命名空間下面的ServiceController 類,System.Management下面的一些WMI操作的類。雖然用ServiceController可以很方便的實(shí)現(xiàn)對(duì)服務(wù)的控制,而且很直觀、簡(jiǎn)潔和容易理解。但是我認(rèn)為他的功能同通過WMI來操作服務(wù)相比,那可能就有些單一了,并且對(duì)多個(gè)服務(wù)的操作可能就比較麻煩,也無法列出系統(tǒng)中的所有服務(wù)的具體數(shù)據(jù)。這里要講的就是如何使用System.Management組件來操作遠(yuǎn)程和本地計(jì)算機(jī)上的服務(wù)。
WMI作為Windows 2000操作系統(tǒng)的一部分提供了可伸縮的,可擴(kuò)展的管理架構(gòu).公共信息模型(CIM)是由分布式管理任務(wù)標(biāo)準(zhǔn)協(xié)會(huì)(DMTF)設(shè)計(jì)的一種可擴(kuò)展的、面向?qū)ο蟮募軜?gòu),用于管理系統(tǒng)、網(wǎng)絡(luò)、應(yīng)用程序、數(shù)據(jù)庫和設(shè)備。Windows管理規(guī)范也稱作CIM for Windows,提供了統(tǒng)一的訪問管理信息的方式。如果需要獲取詳細(xì)的WMI信息請(qǐng)讀者查閱MSDN。System.Management組件提供對(duì)大量管理信息和管理事件集合的訪問,這些信息和事件是與根據(jù) Windows 管理規(guī)范 (WMI) 結(jié)構(gòu)對(duì)系統(tǒng)、設(shè)備和應(yīng)用程序設(shè)置檢測(cè)點(diǎn)有關(guān)的。
但是上面并不是我們最關(guān)心的,下面才是我們需要談的話題。
毫無疑問,我們要引用System.Management.Dll程序集,并要使用System.Management命名空間下的類,如ManagementClass,ManagementObject等。下面用一個(gè)名為Win32ServiceManager的類把服務(wù)的一些相關(guān)操作包裝了一下,代碼如下:
using System;
using System.Management;
namespace ZZ.Wmi
{
public class Win32ServiceManager
{
private string strPath;
private ManagementClass managementClass;
public Win32ServiceManager():this(".",null,null)
{
}
public Win32ServiceManager(string host,string userName,string password)
{
this.strPath = "\\\\"+host+"\\root\\cimv2:Win32_Service";
this.managementClass = new ManagementClass(strPath);
if(userName!=null&&userName.Length>0)
{
ConnectionOptions connectionOptions = new ConnectionOptions();
connectionOptions.Username = userName;
connectionOptions.Password = password;
ManagementScope managementScope = new ManagementScope( "\\\\" +host+ "\\root\\cimv2",connectionOptions) ;
this.managementClass.Scope = managementScope;
}
}
// 驗(yàn)證是否能連接到遠(yuǎn)程計(jì)算機(jī)
public static bool RemoteConnectValidate(string host,string userName,string password)
{
ConnectionOptions connectionOptions = new ConnectionOptions();
connectionOptions.Username = userName;
connectionOptions.Password = password;
ManagementScope managementScope = new ManagementScope( "\\\\" +host+ "\\root\\cimv2",connectionOptions) ;
try
{
managementScope.Connect();
}
catch
{
}
return managementScope.IsConnected;
}
// 獲取指定服務(wù)屬性的值
public object GetServiceValue(string serviceName,string propertyName)
{
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
return mo[propertyName];
}
// 獲取所連接的計(jì)算機(jī)的所有服務(wù)數(shù)據(jù)
public string [,] GetServiceList()
{
string [,] services = new string [this.managementClass.GetInstances().Count,4];
int i = 0;
foreach(ManagementObject mo in this.managementClass.GetInstances())
{
services[i,0] = (string)mo["Name"];
services[i,1] = (string)mo["DisplayName"];
services[i,2] = (string)mo["State"];
services[i,3] = (string)mo["StartMode"];
i++;
}
return services;
}
// 獲取所連接的計(jì)算機(jī)的指定服務(wù)數(shù)據(jù)
public string [,] GetServiceList(string serverName)
{
return GetServiceList(new string []{serverName});
}
// 獲取所連接的計(jì)算機(jī)的的指定服務(wù)數(shù)據(jù)
public string [,] GetServiceList(string [] serverNames)
{
string [,] services = new string [serverNames.Length,4];
ManagementObject mo = this.managementClass.CreateInstance();
for(int i = 0;i<serverNames.Length;i++)
{
mo.Path = new ManagementPath(this.strPath+".Name=\""+serverNames[i]+"\"");
services[i,0] = (string)mo["Name"];
services[i,1] = (string)mo["DisplayName"];
services[i,2] = (string)mo["State"];
services[i,3] = (string)mo["StartMode"];
}
return services;
}
// 停止指定的服務(wù)
public string StartService(string serviceName)
{
string strRst = null;
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
try
{
if((string)mo["State"]=="Stopped")//!(bool)mo["AcceptStop"]
mo.InvokeMethod("StartService",null);
}
catch(ManagementException e)
{
strRst =e.Message;
}
return strRst;
}
// 暫停指定的服務(wù)
public string PauseService(string serviceName)
{
string strRst = null;
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
try
{
//判斷是否可以暫停
if((bool)mo["acceptPause"]&&(string)mo["State"]=="Running")
mo.InvokeMethod("PauseService",null);
}
catch(ManagementException e)
{
strRst =e.Message;
}
return strRst;
}
// 恢復(fù)指定的服務(wù)
public string ResumeService(string serviceName)
{
string strRst = null;
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
try
{
//判斷是否可以恢復(fù)
if((bool)mo["acceptPause"]&&(string)mo["State"]=="Paused")
mo.InvokeMethod("ResumeService",null);
}
catch(ManagementException e)
{
strRst =e.Message;
}
return strRst;
}
// 停止指定的服務(wù)
public string StopService(string serviceName)
{
string strRst = null;
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
try
{
//判斷是否可以停止
if((bool)mo["AcceptStop"])//(string)mo["State"]=="Running"
mo.InvokeMethod("StopService",null);
}
catch(ManagementException e)
{
strRst =e.Message;
}
return strRst;
}
}
}
在Win32ServiceManager中通過RemoteConnectValidate靜態(tài)方法來測(cè)試連接成功與否;另外提供了GetServiceValue方法和GetServiceList方法以及它的重載來獲取服務(wù)信息;后面的四個(gè)方法就是對(duì)服務(wù)的狀態(tài)控制了。
下面建立一個(gè)簡(jiǎn)單的窗口來使用它。
大致的界面如下:
通過vs.net 2003可以很快做出上面的窗體,下面列出了一些增加的代碼:
using ZZ.Wmi;
namespace ZZForm
{
public class Form1 : System.Windows.Forms.Form
{
//……
private Win32ServiceManager serviceManager;
public Form1()
{
InitializeComponent();
this.serviceManager = null;
}
//……
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//修改服務(wù)狀態(tài)
private void buttonChangeState_Click(object sender, System.EventArgs e)
{
switch(((Button)sender).Text)
{
case "啟動(dòng)":
string startRst = this.serviceManager.StartService(this.listViewService.SelectedItems[0].SubItems[0].Text);
if(startRst==null)
MessageBox.Show("操作成功,請(qǐng)點(diǎn)擊獲取刷新按鈕刷新結(jié)果!");
else
MessageBox.Show(startRst);
break;
case "暫停":
string startPause = this.serviceManager.PauseService(this.listViewService.SelectedItems[0].SubItems[0].Text);
if(startPause==null)
MessageBox.Show("操作成功,請(qǐng)點(diǎn)擊獲取刷新按鈕刷新結(jié)果!");
else
MessageBox.Show(startPause);
break;
case "繼續(xù)":
string startResume = this.serviceManager.ResumeService(this.listViewService.SelectedItems[0].SubItems[0].Text);
if(startResume==null)
MessageBox.Show("操作成功,請(qǐng)點(diǎn)擊獲取刷新按鈕刷新結(jié)果!");
else
MessageBox.Show(startResume);
break;
case "停止":
string startStop = this.serviceManager.StopService(this.listViewService.SelectedItems[0].SubItems[0].Text);
if(startStop==null)
MessageBox.Show("操作成功,請(qǐng)點(diǎn)擊獲取刷新按鈕刷新結(jié)果!");
else
MessageBox.Show(startStop);
break;
}
}
//獲取和刷新數(shù)據(jù)
private void buttonLoadRefresh_Click(object sender, System.EventArgs e)
{
if(this.textBoxHost.Text.Trim().Length>0)
{
if(this.textBoxHost.Text.Trim()==".")
{
this.serviceManager = new Win32ServiceManager();
}
else
{
if(Win32ServiceManager.RemoteConnectValidate(this.textBoxHost.Text.Trim(),this.textBoxName.Text.Trim(),this.textBoxPassword.Text.Trim()))
{
this.serviceManager = new Win32ServiceManager(this.textBoxHost.Text.Trim(),this.textBoxName.Text.Trim(),this.textBoxPassword.Text.Trim());
}
else
{
MessageBox.Show("連接到遠(yuǎn)程計(jì)算機(jī)驗(yàn)證錯(cuò)誤.");
return;
}
}
string [,] services = serviceManager.GetServiceList();
this.listViewService.BeginUpdate();
this.listViewService.Items.Clear();
for(int i=0;i<services.GetLength(0);i++)
{
ListViewItem item = new ListViewItem(new string[]{services[i,0],services[i,1],services[i,2],services[i,3]});
this.listViewService.Items.Add(item);
}
this.listViewService.EndUpdate();
}
else
MessageBox.Show("請(qǐng)輸入計(jì)算機(jī)名或IP地址");
}
}
}
說明,其實(shí)一個(gè)服務(wù)的屬性和方法除了上面這幾個(gè)還有很多,我們可以通過實(shí)例化ManagementClass類,使用它的Properties屬性和Methods屬性列出所有的屬性和方法。上面的Win32ServiceManager中生成的每個(gè)服務(wù)實(shí)例都是ManagementObejct類型的,其實(shí)還有一種強(qiáng)類型的類,可以通過編程和工具來生成。
總結(jié),通過引用System.Management命名空間,上面簡(jiǎn)單的實(shí)現(xiàn)了通過訪問\root\cimv2:Win32_Service名稱空間對(duì)服務(wù)進(jìn)行顯示和操作。此外,我們還可以通過訪問其他名稱空間來訪問計(jì)算機(jī)的一些硬件信息,軟件信息以及網(wǎng)絡(luò)等,有興趣的讀者可以研究一下。
WMI作為Windows 2000操作系統(tǒng)的一部分提供了可伸縮的,可擴(kuò)展的管理架構(gòu).公共信息模型(CIM)是由分布式管理任務(wù)標(biāo)準(zhǔn)協(xié)會(huì)(DMTF)設(shè)計(jì)的一種可擴(kuò)展的、面向?qū)ο蟮募軜?gòu),用于管理系統(tǒng)、網(wǎng)絡(luò)、應(yīng)用程序、數(shù)據(jù)庫和設(shè)備。Windows管理規(guī)范也稱作CIM for Windows,提供了統(tǒng)一的訪問管理信息的方式。如果需要獲取詳細(xì)的WMI信息請(qǐng)讀者查閱MSDN。System.Management組件提供對(duì)大量管理信息和管理事件集合的訪問,這些信息和事件是與根據(jù) Windows 管理規(guī)范 (WMI) 結(jié)構(gòu)對(duì)系統(tǒng)、設(shè)備和應(yīng)用程序設(shè)置檢測(cè)點(diǎn)有關(guān)的。
但是上面并不是我們最關(guān)心的,下面才是我們需要談的話題。
毫無疑問,我們要引用System.Management.Dll程序集,并要使用System.Management命名空間下的類,如ManagementClass,ManagementObject等。下面用一個(gè)名為Win32ServiceManager的類把服務(wù)的一些相關(guān)操作包裝了一下,代碼如下:
using System;
using System.Management;
namespace ZZ.Wmi
{
public class Win32ServiceManager
{
private string strPath;
private ManagementClass managementClass;
public Win32ServiceManager():this(".",null,null)
{
}
public Win32ServiceManager(string host,string userName,string password)
{
this.strPath = "\\\\"+host+"\\root\\cimv2:Win32_Service";
this.managementClass = new ManagementClass(strPath);
if(userName!=null&&userName.Length>0)
{
ConnectionOptions connectionOptions = new ConnectionOptions();
connectionOptions.Username = userName;
connectionOptions.Password = password;
ManagementScope managementScope = new ManagementScope( "\\\\" +host+ "\\root\\cimv2",connectionOptions) ;
this.managementClass.Scope = managementScope;
}
}
// 驗(yàn)證是否能連接到遠(yuǎn)程計(jì)算機(jī)
public static bool RemoteConnectValidate(string host,string userName,string password)
{
ConnectionOptions connectionOptions = new ConnectionOptions();
connectionOptions.Username = userName;
connectionOptions.Password = password;
ManagementScope managementScope = new ManagementScope( "\\\\" +host+ "\\root\\cimv2",connectionOptions) ;
try
{
managementScope.Connect();
}
catch
{
}
return managementScope.IsConnected;
}
// 獲取指定服務(wù)屬性的值
public object GetServiceValue(string serviceName,string propertyName)
{
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
return mo[propertyName];
}
// 獲取所連接的計(jì)算機(jī)的所有服務(wù)數(shù)據(jù)
public string [,] GetServiceList()
{
string [,] services = new string [this.managementClass.GetInstances().Count,4];
int i = 0;
foreach(ManagementObject mo in this.managementClass.GetInstances())
{
services[i,0] = (string)mo["Name"];
services[i,1] = (string)mo["DisplayName"];
services[i,2] = (string)mo["State"];
services[i,3] = (string)mo["StartMode"];
i++;
}
return services;
}
// 獲取所連接的計(jì)算機(jī)的指定服務(wù)數(shù)據(jù)
public string [,] GetServiceList(string serverName)
{
return GetServiceList(new string []{serverName});
}
// 獲取所連接的計(jì)算機(jī)的的指定服務(wù)數(shù)據(jù)
public string [,] GetServiceList(string [] serverNames)
{
string [,] services = new string [serverNames.Length,4];
ManagementObject mo = this.managementClass.CreateInstance();
for(int i = 0;i<serverNames.Length;i++)
{
mo.Path = new ManagementPath(this.strPath+".Name=\""+serverNames[i]+"\"");
services[i,0] = (string)mo["Name"];
services[i,1] = (string)mo["DisplayName"];
services[i,2] = (string)mo["State"];
services[i,3] = (string)mo["StartMode"];
}
return services;
}
// 停止指定的服務(wù)
public string StartService(string serviceName)
{
string strRst = null;
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
try
{
if((string)mo["State"]=="Stopped")//!(bool)mo["AcceptStop"]
mo.InvokeMethod("StartService",null);
}
catch(ManagementException e)
{
strRst =e.Message;
}
return strRst;
}
// 暫停指定的服務(wù)
public string PauseService(string serviceName)
{
string strRst = null;
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
try
{
//判斷是否可以暫停
if((bool)mo["acceptPause"]&&(string)mo["State"]=="Running")
mo.InvokeMethod("PauseService",null);
}
catch(ManagementException e)
{
strRst =e.Message;
}
return strRst;
}
// 恢復(fù)指定的服務(wù)
public string ResumeService(string serviceName)
{
string strRst = null;
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
try
{
//判斷是否可以恢復(fù)
if((bool)mo["acceptPause"]&&(string)mo["State"]=="Paused")
mo.InvokeMethod("ResumeService",null);
}
catch(ManagementException e)
{
strRst =e.Message;
}
return strRst;
}
// 停止指定的服務(wù)
public string StopService(string serviceName)
{
string strRst = null;
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
try
{
//判斷是否可以停止
if((bool)mo["AcceptStop"])//(string)mo["State"]=="Running"
mo.InvokeMethod("StopService",null);
}
catch(ManagementException e)
{
strRst =e.Message;
}
return strRst;
}
}
}
在Win32ServiceManager中通過RemoteConnectValidate靜態(tài)方法來測(cè)試連接成功與否;另外提供了GetServiceValue方法和GetServiceList方法以及它的重載來獲取服務(wù)信息;后面的四個(gè)方法就是對(duì)服務(wù)的狀態(tài)控制了。
下面建立一個(gè)簡(jiǎn)單的窗口來使用它。
大致的界面如下:
通過vs.net 2003可以很快做出上面的窗體,下面列出了一些增加的代碼:
using ZZ.Wmi;
namespace ZZForm
{
public class Form1 : System.Windows.Forms.Form
{
//……
private Win32ServiceManager serviceManager;
public Form1()
{
InitializeComponent();
this.serviceManager = null;
}
//……
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//修改服務(wù)狀態(tài)
private void buttonChangeState_Click(object sender, System.EventArgs e)
{
switch(((Button)sender).Text)
{
case "啟動(dòng)":
string startRst = this.serviceManager.StartService(this.listViewService.SelectedItems[0].SubItems[0].Text);
if(startRst==null)
MessageBox.Show("操作成功,請(qǐng)點(diǎn)擊獲取刷新按鈕刷新結(jié)果!");
else
MessageBox.Show(startRst);
break;
case "暫停":
string startPause = this.serviceManager.PauseService(this.listViewService.SelectedItems[0].SubItems[0].Text);
if(startPause==null)
MessageBox.Show("操作成功,請(qǐng)點(diǎn)擊獲取刷新按鈕刷新結(jié)果!");
else
MessageBox.Show(startPause);
break;
case "繼續(xù)":
string startResume = this.serviceManager.ResumeService(this.listViewService.SelectedItems[0].SubItems[0].Text);
if(startResume==null)
MessageBox.Show("操作成功,請(qǐng)點(diǎn)擊獲取刷新按鈕刷新結(jié)果!");
else
MessageBox.Show(startResume);
break;
case "停止":
string startStop = this.serviceManager.StopService(this.listViewService.SelectedItems[0].SubItems[0].Text);
if(startStop==null)
MessageBox.Show("操作成功,請(qǐng)點(diǎn)擊獲取刷新按鈕刷新結(jié)果!");
else
MessageBox.Show(startStop);
break;
}
}
//獲取和刷新數(shù)據(jù)
private void buttonLoadRefresh_Click(object sender, System.EventArgs e)
{
if(this.textBoxHost.Text.Trim().Length>0)
{
if(this.textBoxHost.Text.Trim()==".")
{
this.serviceManager = new Win32ServiceManager();
}
else
{
if(Win32ServiceManager.RemoteConnectValidate(this.textBoxHost.Text.Trim(),this.textBoxName.Text.Trim(),this.textBoxPassword.Text.Trim()))
{
this.serviceManager = new Win32ServiceManager(this.textBoxHost.Text.Trim(),this.textBoxName.Text.Trim(),this.textBoxPassword.Text.Trim());
}
else
{
MessageBox.Show("連接到遠(yuǎn)程計(jì)算機(jī)驗(yàn)證錯(cuò)誤.");
return;
}
}
string [,] services = serviceManager.GetServiceList();
this.listViewService.BeginUpdate();
this.listViewService.Items.Clear();
for(int i=0;i<services.GetLength(0);i++)
{
ListViewItem item = new ListViewItem(new string[]{services[i,0],services[i,1],services[i,2],services[i,3]});
this.listViewService.Items.Add(item);
}
this.listViewService.EndUpdate();
}
else
MessageBox.Show("請(qǐng)輸入計(jì)算機(jī)名或IP地址");
}
}
}
說明,其實(shí)一個(gè)服務(wù)的屬性和方法除了上面這幾個(gè)還有很多,我們可以通過實(shí)例化ManagementClass類,使用它的Properties屬性和Methods屬性列出所有的屬性和方法。上面的Win32ServiceManager中生成的每個(gè)服務(wù)實(shí)例都是ManagementObejct類型的,其實(shí)還有一種強(qiáng)類型的類,可以通過編程和工具來生成。
總結(jié),通過引用System.Management命名空間,上面簡(jiǎn)單的實(shí)現(xiàn)了通過訪問\root\cimv2:Win32_Service名稱空間對(duì)服務(wù)進(jìn)行顯示和操作。此外,我們還可以通過訪問其他名稱空間來訪問計(jì)算機(jī)的一些硬件信息,軟件信息以及網(wǎng)絡(luò)等,有興趣的讀者可以研究一下。
您可能感興趣的文章:
- C#遠(yuǎn)程發(fā)送和接收數(shù)據(jù)流生成圖片的方法
- C#檢測(cè)遠(yuǎn)程計(jì)算機(jī)端口是否打開的方法
- C#實(shí)現(xiàn)遠(yuǎn)程連接ORACLE數(shù)據(jù)庫的方法
- C#實(shí)現(xiàn)查殺本地與遠(yuǎn)程進(jìn)程的方法
- C#同步、異步遠(yuǎn)程下載文件實(shí)例
- c#連接數(shù)據(jù)庫及sql2005遠(yuǎn)程連接的方法
- c#遠(yuǎn)程html數(shù)據(jù)抓取實(shí)例分享
- C#重啟遠(yuǎn)程計(jì)算機(jī)的代碼
- C#實(shí)現(xiàn)控制Windows系統(tǒng)關(guān)機(jī)、重啟和注銷的方法
- C#實(shí)現(xiàn)關(guān)機(jī)重啟及注銷實(shí)例代碼
- C#實(shí)現(xiàn)遠(yuǎn)程關(guān)閉計(jì)算機(jī)或重啟計(jì)算機(jī)的方法
相關(guān)文章
C#實(shí)現(xiàn)winform中RichTextBox在指定光標(biāo)位置插入圖片的方法
這篇文章主要介紹了C#實(shí)現(xiàn)winform中RichTextBox在指定光標(biāo)位置插入圖片的方法,涉及RichTextBox控件及剪切板的相關(guān)操作技巧,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2016-06-06WinForm實(shí)現(xiàn)讀取Resource中文件的方法
這篇文章主要介紹了WinForm實(shí)現(xiàn)讀取Resource中文件的方法,很實(shí)用的一個(gè)功能,需要的朋友可以參考下2014-08-08C#實(shí)現(xiàn)左截取和右截取字符串實(shí)例
這篇文章主要介紹了C#實(shí)現(xiàn)左截取和右截取字符串實(shí)例,是針對(duì)字符串的常用操作,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2014-10-10AOP從靜態(tài)代理到動(dòng)態(tài)代理(Emit實(shí)現(xiàn))詳解
AOP為Aspect Oriented Programming的縮寫,意思是面向切面編程的技術(shù)。下面這篇文章主要給大家介紹了關(guān)于AOP從靜態(tài)代理到動(dòng)態(tài)代理(Emit實(shí)現(xiàn))的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下2018-09-09C# DateTime與時(shí)間戳轉(zhuǎn)換實(shí)例
本篇文章主要介紹了C# DateTime與時(shí)間戳轉(zhuǎn)換實(shí)例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-06-06詳解C# 匿名對(duì)象(匿名類型)、var、動(dòng)態(tài)類型 dynamic
隨著C#的發(fā)展,該語言內(nèi)容不斷豐富,開發(fā)變得更加方便快捷,C# 的鋒利盡顯無疑。下面通過本文給大家分享C# 匿名對(duì)象(匿名類型)、var、動(dòng)態(tài)類型 dynamic,需要的的朋友參考下吧2017-09-09