VS2008代码段快捷方式小记
VS2008代码段快捷方式小记
微软的IDE为程序员提供了很多的方便而之前就看到过园子里的朋友发过关于代码段(Snippet)的文章,最后会列举一些,这里花点时间把除了VAssist X之外的,微软VS2008自带的代码段快捷方式贴一下,希望有用。按字母顺序:
特殊字符
#if true
#endif
~ 析构函数代码段
![]()
代码段#region 代码段
![]()
![]()
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.IEnumeratorElementType> 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.IEnumeratorElementType> GetEnumerator()
![]()
{
for (int i = 0; i this.Length; i++)
![]()
{
yield return this;
}
}
}
——————————————————————————————————————————————————
![]()
![]()
L~Z
lock
![]()
mbox (MessageBox.Show())
namespace
![]()
prop (public int MyProperty
{ get; set; } )
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
{ get; private set; }
sim :
————————————————————————————
static int Main(string[] args)
![]()
{
![]()
return 0;
}
——————————————————————————
struct
——————————————————————————
static void Main(string[] args)
![]()
{
![]()
}
——————————————————————————
switch
try
tryf
unchecked
unsafe
using
wde(依赖属性代码段)
wdp(工作流活动中创建依赖属性代码段)
while
特殊字符
#if true
#endif
~ 析构函数代码段
代码段#region 代码段

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.IEnumeratorElementType> 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.IEnumeratorElementType> GetEnumerator()
{
for (int i = 0; i this.Length; i++)
{
yield return this;
}
}
}
——————————————————————————————————————————————————

L~Z
lock
mbox (MessageBox.Show())
namespace
prop (public int MyProperty
{ get; set; } )
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
{ get; private set; }
sim :
————————————————————————————
static int Main(string[] args)
{
return 0;
}
——————————————————————————
struct
——————————————————————————
static void Main(string[] args)
{
}
——————————————————————————
switch
try
tryf
unchecked
unsafe
using
wde(依赖属性代码段)
wdp(工作流活动中创建依赖属性代码段)
while——————————————————————————
输入一个想产生的方法名, 选中
输入一个想产生的方法名, 选中
Ctrl+K+M
正面猛男![]()
浙公网安备 33010602011771号