以下是从visual studio中整理出来的常用代码片段,以作备忘

快捷键: eh

用途: 类中事件实现函数模板

		private void MyMethod(object sender, EventArgs e)
{
throw new NotImplementedException();
}

快捷键: xmethod 有4个

用途: 类中公有静态方法的函数模板

        public static void MyMethod(this object value)
{
throw new NotImplementedException();
}

快捷键: method 有4个

用途: 类中公有函数的模板

		public void MyMethod()
{
throw new NotImplementedException();
}

快捷键: seh

用途: 类中私有静态方法的函数模板

        private static void MyMethod(object sender, EventArgs e)
{
throw new NotImplementedException();
}

快捷键: smethod 有4个

用途: 类中公有静态方法的函数模板

        public static void MyMethod()
{
throw new NotImplementedException();
}

快捷键: vmethod 有4个

用途: 类中虚函数的模板

        public virtual void MyMethod()
{
throw new NotImplementedException();
}

快捷键: 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 PropertyMetadata(0));

快捷键: 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 PropertyMetadata(0));

快捷键: wde

用途: Windows工作流模式下创建依赖属性事件的模板

        public static System.Workflow.ComponentModel.DependencyProperty InvokeEvent = System.Workflow.ComponentModel.DependencyProperty.Register("Invoke", typeof(EventHandler), typeof(Obj));

        [System.ComponentModel.Description("Invoke")]
[System.ComponentModel.Category("Invoke Category")]
[System.ComponentModel.Browsable(true)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)]
public event EventHandler Invoke
{
add
{
base.AddHandler(Obj.InvokeEvent, value);
}
remove
{
base.RemoveHandler(Obj.InvokeEvent, value);
}
}

快捷键: wdp

        public static System.Workflow.ComponentModel.DependencyProperty MyPropertyProperty = System.Workflow.ComponentModel.DependencyProperty.Register("MyProperty", typeof(string), typeof(Obj));

        [System.ComponentModel.Description("MyProperty")]
[System.ComponentModel.Category("MyProperty Category")]
[System.ComponentModel.Browsable(true)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)]
public string MyProperty
{
get
{
return ((string)(base.GetValue(Obj.MyPropertyProperty)));
}
set
{
base.SetValue(Obj.MyPropertyProperty, value);
}
}

快捷键: testc

用途: 新建一个C#的测试单元类的模板

        [Microsoft.VisualStudio.TestTools.UnitTesting.TestClass]
public class MyTestClass
{ }

快捷键: testm

用途: 在C#的测试单元类中新增一个测试方法

        [TestMethod]
public void MyTestMethod()
{ }

C#常用代码片段备忘的更多相关文章

  1. 36个Android开发常用代码片段

    //36个Android开发常用代码片段 //拨打电话 public static void call(Context context, String phoneNumber) { context.s ...

  2. ExtJs4常用配置方法备忘

    viewport布局常用属性 new Ext.Viewport({ layout: "border", renderTo: Ext.getBody(), defaults: { b ...

  3. Jquery学习总结(1)——Jquery常用代码片段汇总

    1. 禁止右键点击 ? 1 2 3 4 5 $(document).ready(function(){     $(document).bind("contextmenu",fun ...

  4. jQuery常用代码片段

    检测IE浏览器 在进行CSS设计时,IE浏览器对开发者及设计师而言无疑是个麻烦.尽管IE6的黑暗时代已经过去,IE浏览器家族的人气亦在不断下滑,但我们仍然有必要对其进行检测.当然,以下片段亦可用于检测 ...

  5. 常用linux命令备忘

    备忘: 关闭防火墙:# systemctl stop firewalld 查看防火墙状态:#  systemctl status firewalld 停止防火墙:#  systemctl disabl ...

  6. Vue3.0常用代码片段和开发插件

    Vue3 Snippets for Visual Studio Code Vue3 Snippets源码 Vue3 Snippets下载 This extension adds Vue3 Code S ...

  7. Ext.NET Ext.JS 常用代码片段摘录

    引言 最近写代码突然有"一把梭"的感觉, 不管三七二十一先弄上再说. 换别人的说法, 这应该是属于"做项目"风格法吧. 至于知识体系, 可以参考官方或者更权威的 ...

  8. Play常用代码片段 http://www.anool.net/?p=625

    持续更新中: (1)按照降序查询: List<Entity> entities= Entity.find("order by id desc").fetch(2);   ...

  9. mysql 常用命令(备忘)

    1:使用SHOW语句找出在服务器上当前存在什么数据库: mysql> SHOW DATABASES; 2:2.创建一个数据库MYSQLDATA mysql> CREATE DATABASE ...

随机推荐

  1. parsing XML document from class path resource [config/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [config/applicationContext.xml] 解决方案

    parsing XML document from class path resource [config/applicationContext.xml]; nested exception is j ...

  2. HTML 5  标签

    HTML 5 标签 标签定义文档中的节(section.区段).比如章节.页眉.页脚或文档中的其他部分. E 9+.Firefox.Opera.Chrome 和 Safari 标签. 注释:IE 8 ...

  3. dedecms织梦自定义表单发送到邮箱-用163邮箱发送邮件

    https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=monline_3_dg&wd=dedecms 邮箱&oq=d ...

  4. 滑稽的下午--angularjs 2.0管道的使用

    虽然angular 已经迎来4.0时代,可我还在苦逼的看2.0. 下午有个任务: 让一个component组件里的时间显示当前时间并自动刷新. 过程: 1.首先获取当前时间 new Date(); 2 ...

  5. intellij-项目目录隐藏无用的文件和文件夹

    File-->Editor-->File Types

  6. WEB安全_csrf攻击

    什么是xss跨站攻击? 正常访问服务器A,用户信任并在服务器A上登录操作,服务器A保存着用户的session数据,这时用户并没有退出服务器A的系统,然后访问危险服务器B,本来是用户请求服务器返回数据, ...

  7. Django_404_403_500页面处理

    需求: 进入上线环境,用户并没有权力知道出错信息,那我们需要对不同的出错信息返回不同页面提示,提升用户的体验 问题原因: 生产环境下,用户输入的url地址不正确,没有对应的view去处理这个url请求 ...

  8. POI--HSSFRow类

    用POI在工作表里作成一个行,可以用「HSSFRow」类,它的构造方法有三个. protected HSSFRow() protected HSSFRow(Workbook book, Sheet s ...

  9. 自己用的一套reset.css,打算整理一下方便以后用,持续更新中,各位大神,不喜勿喷

    *{margin: 0; padding: 0;border:none;}img{vertical-align: top;width: 100%;border: none;}ul,li{list-st ...

  10. spark-遇到问题小结

     经常会遇到 类似 shuffle 0 的错误,或者 connect refuse .主要是shuffle 导致内存不足引起的.shuffle 分为 shuffle read 和write . 1. ...