痛而后能善
无惧于闯
Make a greate impact

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

VS2008代码段快捷方式小记
微软的IDE为程序员提供了很多的方便而之前就看到过园子里的朋友发过关于代码段(Snippet)的文章,最后会列举一些,这里花点时间把除了VAssist X之外的,微软VS2008自带的代码段快捷方式贴一下,希望有用。按字母顺序:

特殊字符

#if true
#endif
~ 析构函数代码段
代码段

A~J

复制代码



Attribute (属性模型代码段)
checked
class
ctor (构造函数)
cw   (Console.WriteLine代码段)
do
else
enum (枚举)
equals代码段
Exception

for
foreach
forr (for逆向代码段)

if
indexer(索引器)
interface(代码段)
invoke(安全调用事件代码段)
iterator(简单迭代器代码段)
——————————简单迭代器代码段示例——————————————————————
public System.Collections.Generic.IEnumerator<ElementType> GetEnumerator()
        
{
            
throw new NotImplementedException();
            
yield return default(ElementType);
        }

——————————————————————————————————————————
iterindex
——————————iterindex示例——————————————————————————————
 
public MyViewIterator MyView
        
{
            
get
            
{
                
return new MyViewIterator(this);
            }

        }


        
public class MyViewIterator
        
{
            
readonly TypeSystem outer;

            
internal MyViewIterator(TypeSystem outer)
            
{
                
this.outer = outer;
            }


            
// TODO: provide an appropriate implementation here
            public int Length get return 1; } }

            
public ElementType this[int index]
            
{
                
get
                
{
                    
//
                    
// TODO: implement indexer here
                    
//
                    
// you have full access to TypeSystem privates
                    
//
                    throw new NotImplementedException();
                    
return default(ElementType);
                }

            }


            
public System.Collections.Generic.IEnumerator<ElementType> GetEnumerator()
            
{
                
for (int i = 0; i < this.Length; i++)
                
{
                    
yield return this[i];
                }

            }

        }

——————————————————————————————————————————————————

复制代码

L~Z

复制代码
lock

mbox (MessageBox.Show())
namespace
prop (
public int MyProperty getset; } )
propa 
——————————————————————————————————————————————————————
        
public static int GetMyProperty(DependencyObject obj)
        
{
            
return (int)obj.GetValue(MyPropertyProperty);
        }


        
public static void SetMyProperty(DependencyObject obj, int value)
        
{
            obj.SetValue(MyPropertyProperty, value);
        }


        
// Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc
        public static readonly DependencyProperty MyPropertyProperty =
            DependencyProperty.RegisterAttached(
"MyProperty"typeof(int), typeof(ownerclass), new UIPropertyMetadata(0));

——————————————————————————————————————————————————————
propdp
——————————————————————————————————————————————————————
        
public int MyProperty
        
{
            
get return (int)GetValue(MyPropertyProperty); }
            
set { SetValue(MyPropertyProperty, value); }
        }


        
// Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc
        public static readonly DependencyProperty MyPropertyProperty =
            DependencyProperty.Register(
"MyProperty"typeof(int), typeof(ownerclass), new UIPropertyMetadata(0));
——————————————————————————————————————————————————————
propg :         
public int MyProperty getprivate set; }
sim :
————————————————————————————
        
static int Main(string[] args)
        
{

            
return 0;
        }

——————————————————————————
struct
——————————————————————————
static void Main(string[] args)
        
{

        }

——————————————————————————
switch
try
tryf
unchecked
unsafe
using
wde(依赖属性代码段)
wdp(工作流活动中创建依赖属性代码段)
while
复制代码

相关文章:
http://www.cnblogs.com/shanyou/archive/2007/11/20/965024.html
http://www.infoq.com/news/2007/11/SnippetEditor
http://www.cnblogs.com/xiaoxijin/archive/2007/03/30/694569.html
http://www.cnblogs.com/xiaoshatian/archive/2006/12/31/608479.html
http://www.cnblogs.com/heekui/archive/2007/03/13/672532.html
http://www.cnblogs.com/island/archive/2007/10/04/cscodesnippet.html
.......
还有很多,不一一列举了 :)

posted on   greater  阅读(1777)  评论(2编辑  收藏  举报

编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端
点击右上角即可分享
微信分享提示