Calls to C # methods

Source: Internet
Author: User

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespaceTemporary8 {9     class PersonTen     { One          Public classClass1 A         { -              Public Static voidMethod () -             { theConsole.WriteLine ("the static method can be called directly! But it's a very expensive source! "); -             } -              Public voidMethod1 () -             { +Console.WriteLine ("non-static method to create an object to access! "); -             } +              Public voidMethod2 () A             { atMethod1 ();//the method body in the same class can directly access both static and non-static PS: The invocation of a method in a homogeneous way, the method name can be written directly - Method (); -             } -         } -         class Program -         { in             Static voidMain (string[] args) -             { toClass1.method ();//Access static method PS: The invocation of a static method is directly the class name. Method +Class1 obj =NewClass1 ();//Create object PS: A call to a non-static method: Calling a method in another class must be public and the instance name. Method -Obj. Method1 ();//access to a non-static method; the             } *         } $     }Panax Notoginseng}

Calls to C # methods

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.