以下是从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. 自己编写JavaScript的sort函数

    在平常开发中我们经常会遇到对数组进行排序的场景,js给我们提供了sort方法可以对数组元素进行排序,默认是按ASCII字母表顺序排序,请看下面例子: var a = [1, 3, 2, 4];var ...

  2. python网络编程(进程与多线程)

    multiprocessing模块 由于GIL的存在,python中的多线程其实并不是真正的多线程,如果想要充分地使用多核CPU的资源,在python中大部分情况需要使用多进程. multiproce ...

  3. 利用JAVA API远程进行HDFS的相关操作

    学习HDFS有一段时间了,现在把自己总结的HDFS的相关操作代码展示给大家. 主要有HDFS的增删改查,文件的追加,windows本地文件的上传,hdfs文件的下载,文件重命名,创建目录,文件是否存在 ...

  4. WinSCP怎么导入filezilla中的站点?

    WinSCP是一款优秀的图形界面,远程文件管理工具,其出色的图形化界面与windows完美集成,是运用在windows上与远程服务器安全传输文件的软件之一 工具/原料 winscp 方法/步骤 下载. ...

  5. JAR包介绍大全用途作用详解JAVA

    jta.jar 标准JTA API必要commons-collections.jar 集合类 必要antlr.jar  ANother Tool for Language Recognition 必要 ...

  6. Hadoop问题:Incorrect configuration: namenode address dfs.namenode.rpc-address is not configured

    问题描述:Incorrect configuration: namenode address dfs.namenode.rpc-address is not configured 问题分析:core- ...

  7. java.lang.NoClassDefFoundError: javax/mail/Authenticator

    摘录自:http://stackoverflow.com/questions/1630002/java-lang-noclassdeffounderror-javax-mail-authenticat ...

  8. iOS学习——获取当前最顶层的ViewController

    在iOS开发过程中,我们经常性会需要获取当前页面的ViewController,然后利用ViewController进行一些操作,例如在最顶层的ViewController上展示一个UIAlertCo ...

  9. BSA Network Shell系列-通过NSH执行Powershell,VBScript或bat files脚本

    参考:Running Powershell, VBScript, or bat files via NSH 如果你直接在NSH命令行执行的话,可以参考我翻译的下面的东东,如果想运行NSH 脚本作业的话 ...

  10. 五、Html表单标签

    表单,表单控件的主要作用就是收集用户体验,当用户提交表单时,用户输入的内容将作为请求参数提交到远程服务器. 1,form标签 <form>:创建表单,该元素不会生成可视化的界面,但是其他控 ...