刚才偶然发现MSDN网站上放出了微软开发的一些针对VS2005的Code Snippet Libraries,里面提供了很多封装好的代码片断,可以直接拿来使用。
下载地址分别是:
C#: http://msdn.microsoft.com/vstudio/downloads/codesnippets/default.aspx
VB.NET: http://msdn.microsoft.com/vbasic/downloads/snippets/default.aspx
VSTO: http://msdn.microsoft.com/office/understanding/vsto/training/snippets/default.aspx
我自己只下载了C#部分的,总共14个分类(Application, Collections, Connectivity, Crystal Reports, Database, Datatypes, File System, Math, OS, Refectoring, Security, Smart Devices, Windows Forms, XML)大约300个代码片断。
举例,如果我要使用关于Smart Device部分的代码片断,只需要在代码编辑器中输入sd(所有的Smart Device的Code Snippet都是以sd开头),则会自动列出来sd开头的代码片断快捷,例如,我只需要输入sdmemory,然后按一下Tab键,则自动会生成查询Windows Mobile设备当前可用内存的代码片断:
[System.Runtime.InteropServices.DllImport("CoreDll.Dll")]
public static extern int GlobalMemoryStatus(ref MEMORYSTATUS ms);
![](/Images/OutliningIndicators/None.gif)
[System.Runtime.InteropServices.DllImport("CoreDll.Dll")]
public static extern int GetSystemMemoryDivision(ref uint lpdwStorePages, ref uint ldpwRamPages, ref uint ldpwPageSize);
![](/Images/OutliningIndicators/None.gif)
public static MEMORYSTATUS GetMemory()
{
MEMORYSTATUS memStatus = new MEMORYSTATUS();
GlobalMemoryStatus(ref memStatus);
![](/Images/OutliningIndicators/InBlock.gif)
return memStatus;
}
看看,不错吧。。。。呵呵。。。好好研究研究会发现里面有好多不错的代码片断你可以用上呢~~~
下载地址分别是:
C#: http://msdn.microsoft.com/vstudio/downloads/codesnippets/default.aspx
VB.NET: http://msdn.microsoft.com/vbasic/downloads/snippets/default.aspx
VSTO: http://msdn.microsoft.com/office/understanding/vsto/training/snippets/default.aspx
我自己只下载了C#部分的,总共14个分类(Application, Collections, Connectivity, Crystal Reports, Database, Datatypes, File System, Math, OS, Refectoring, Security, Smart Devices, Windows Forms, XML)大约300个代码片断。
举例,如果我要使用关于Smart Device部分的代码片断,只需要在代码编辑器中输入sd(所有的Smart Device的Code Snippet都是以sd开头),则会自动列出来sd开头的代码片断快捷,例如,我只需要输入sdmemory,然后按一下Tab键,则自动会生成查询Windows Mobile设备当前可用内存的代码片断:
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
看看,不错吧。。。。呵呵。。。好好研究研究会发现里面有好多不错的代码片断你可以用上呢~~~