C # Common Code snippet Memo

Source: Internet
Author: User

The following are common code snippets from Visual Studio for memo shortcuts: EH uses: Class event implementation function templates
        private void MyMethod(object sender, EventArgs e)        {            throw new NotImplementedException();        }
Shortcut keys: Xmethod has 4 uses: function templates for public static methods in classes
        public static void MyMethod(this object value)        {            throw new NotImplementedException();        }
Shortcut keys: Method has 4 uses: a template for public functions in a class
        public void MyMethod()        {            throw new NotImplementedException();        }
Shortcut keys: Seh use: function templates for private static methods in classes
        private static void MyMethod(object sender, EventArgs e)        {            throw new NotImplementedException();        }   
Shortcut keys: Smethod has 4 uses: function templates for public static methods in classes
        public static void MyMethod()        {            throw new NotImplementedException();        }
Shortcut key: Vmethod has 4 uses: template of virtual function in class
        public virtual void MyMethod()        {            throw new NotImplementedException();        }
Shortcut key: PROPDP Purpose: Define a template for dependency properties
        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));
Shortcut key: Propa Purpose: A template that defines additional properties
        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));
Shortcut key: Wde use: Create a template for dependency property events in Windows Workflow mode
        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);            }        }
Shortcut key: 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);            }        }
Shortcut key: TESTC use: Create a template for a test unit class of C #
        [Microsoft.VisualStudio.TestTools.UnitTesting.TestClass]        public class MyTestClass        {        }
Shortcut key: testm use: Add a test method to the test unit class in C #
        [TestMethod]        public void MyTestMethod()        {        }   

C # Common Code snippet Memo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.