C#常用代码片段备忘
以下是从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#常用代码片段备忘的更多相关文章
- 36个Android开发常用代码片段
//36个Android开发常用代码片段 //拨打电话 public static void call(Context context, String phoneNumber) { context.s ...
- ExtJs4常用配置方法备忘
viewport布局常用属性 new Ext.Viewport({ layout: "border", renderTo: Ext.getBody(), defaults: { b ...
- Jquery学习总结(1)——Jquery常用代码片段汇总
1. 禁止右键点击 ? 1 2 3 4 5 $(document).ready(function(){ $(document).bind("contextmenu",fun ...
- jQuery常用代码片段
检测IE浏览器 在进行CSS设计时,IE浏览器对开发者及设计师而言无疑是个麻烦.尽管IE6的黑暗时代已经过去,IE浏览器家族的人气亦在不断下滑,但我们仍然有必要对其进行检测.当然,以下片段亦可用于检测 ...
- 常用linux命令备忘
备忘: 关闭防火墙:# systemctl stop firewalld 查看防火墙状态:# systemctl status firewalld 停止防火墙:# systemctl disabl ...
- Vue3.0常用代码片段和开发插件
Vue3 Snippets for Visual Studio Code Vue3 Snippets源码 Vue3 Snippets下载 This extension adds Vue3 Code S ...
- Ext.NET Ext.JS 常用代码片段摘录
引言 最近写代码突然有"一把梭"的感觉, 不管三七二十一先弄上再说. 换别人的说法, 这应该是属于"做项目"风格法吧. 至于知识体系, 可以参考官方或者更权威的 ...
- Play常用代码片段 http://www.anool.net/?p=625
持续更新中: (1)按照降序查询: List<Entity> entities= Entity.find("order by id desc").fetch(2); ...
- mysql 常用命令(备忘)
1:使用SHOW语句找出在服务器上当前存在什么数据库: mysql> SHOW DATABASES; 2:2.创建一个数据库MYSQLDATA mysql> CREATE DATABASE ...
随机推荐
- haslib 模块
一.模块简介 Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 什么是摘要算法呢?摘要算法又称哈希算法.散列算法.它通过一个函数,把任意长度的数据转换为一个长度固定的数据串( ...
- VMware workstation 虚拟机中安装乌班图及其兼容性问题
之前我在虚拟机中安装乌班图,是先安装好虚拟机,然后将预先下载好的乌班图镜像文件导入安装,这样安装起来还是有些繁琐的,中间要设置好多东西.今天领导给我拷了个虚拟机,还有乌班图的安装文件,是这样的. 对于 ...
- Spring MVC集成Swagger
什么是Swagger? 大部分 Web 应用程序都支持 RESTful API,但不同于 SOAP API——REST API 依赖于 HTTP 方法,缺少与 Web 服务描述语言(Web Servi ...
- MySQL的Illegal mix of collationsy异常原因和解决方法
原创 2008年12月25日 11:54:00 标签: mysql / collation / character / variables / database / server 今天在使用数据库 ...
- async函数解析
转载请注明出处:async函数解析 async函数是基于Generator函数实现的,也就是说是Generator函数的语法糖.在之前的文章有介绍过Generator函数语法和异步应用,如果对其不了解 ...
- NSDateFormatter相关整理
//实例化一个NSDateFormatter对象NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; //设定时间格式,这里可 ...
- Java 反射和内省实现spring的IOC和DI
1.构造两个JavaBean package com.spring.model; public class People { private Car car; public Car getCar() ...
- maven项目生成war包
配置 你的pom.xml文件,在你的overview视窗里 配置 packaging为 war 然后添加 <plugin> <groupId>org.apache.maven. ...
- 如何 Scale Up/Down Deployment?- 每天5分钟玩转 Docker 容器技术(126)
伸缩(Scale Up/Down)是指在线增加或减少 Pod 的副本数.Deployment nginx-deployment 初始是两个副本. k8s-node1 和 k8s-node2 上各跑了一 ...
- ANSI C与C89、C99、C11区别差异
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...