以下是从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. powerdesign

  2. 使用Eclipse在Excel中找出两张表中相同证件号而姓名或工号却出现不同的的项

    1:首先把Excel中的文本复制到txt中,复制如下: A表: 证件号                           工号  姓名 310110xxxx220130004 101 傅家宜3101 ...

  3. UE4 内容示例网络同步Learn

    一, 1.1 Actor的复制 Actor中的Replicates ,为true时,服务器会把该Actor同步,显示在客户端中. 1.2 Switch Has Authority判断是客户端还是服务器 ...

  4. Spark算子--SortByKey

    转载请标明出处http://www.cnblogs.com/haozhengfei/p/076a31e7caab1316b07990c02ac65e9c.html  SortByKey--Transf ...

  5. 关于nginx中不用.htaccess 用在ningx.conf中配置的问题

    官网一直出现http://4**.**..7/php/index.php/admin/base/getConfigs报错404错误问题, 问题一:URL重写问题(nginx配置问题) 问题二:vue中 ...

  6. C#进行CAD二次开发环境配置

    最近被公司分配到了做CAD二次开发.也是初次接触这方面的东西,其实是有些无从下手的感觉.因为公司这边也没有人有时间带我,只能是自己看书,然后再写一些Demo,再结合实际的应用来一点点的学习.废话不多说 ...

  7. 【开发技术】Java生成验证码

    Java生成验证码 为了防止用户恶意,或者使用软件外挂提交一些内容,就得用验证码来阻止,虽然这个会影响用户体验,但为了避免一些问题很多网站都使用了验证码;今天下午参考文档弄了一个验证码,这里分享一下; ...

  8. 5dfda1332b67817b0f2d7839242021ce'Java数据结构和算法

    1.return 一个空的集合,而不是 null 如果一个程序返回一个没有任何值的集合,请确保一个空集合返回,而不是空元素.这样你就不用去写一大堆 "if else" 判断null ...

  9. tomcat三种启动不同的启动方式

    Linux下tomcat服务的启动.关闭与错误跟踪,通常通过以下几种方式启动关闭tomcat服务: 切换到tomcat主目录下的bin目录 1. 启动tomcat服务 方式一:直接启动 ./start ...

  10. arduino笔记

    接下来,初来博客,准备自己也写一系列的arduino的学习经验. http://zhongbest.com/2017/05/23/arduino%e4%b8%ad%e7%9a%84%e4%b8%ad% ...