The class definition of C # can contain two methods: Static and Non-static. A static modifier is used, whereas the other is non-static.
A static method is a special member method that does not belong to a specific instance of a class. Non-static
We all know that the member functions of the classes in C + + provide the this pointer by default, and in non-static member functions, when you call a function, the compiler will "automatically" help you add the this pointer to the function
Error reason: A public String getcontent () method and a main () method are written in a class, and the GetContent () method contains the GetClass () method, which is called directly in the main () method GetContent () There is a mistake of the
If a member in a class is declared as static, the member is called a quiescent member. The members in the class are either static or non-static. Generally, static members belong to the class, and non-static members are instances of the class-objects.
1. Static and non-static members can appear in non-static classesusingSystem;namespaceshuzu{classDom_class { Public stringName ="Zhang San"; Private intAge ; Public intAge//accessing private members through properties {
The type descriptor for a static variable is static. Static variables, of course, are static storage, but the amount of static storage is not necessarily static variables, such as external variables are static storage, but not necessarily static
Memory Allocation
Static variables in ApplicationProgramIt exists in the memory during initialization and disappears only when the program running of the class where it is located is completed;
Non-static variables need to be instantiated
In this paper, the static and Non-static methods of C # are analyzed, and their usage is analyzed comprehensively. Share to everyone for your reference. The specific analysis is as follows:
In general, C # classes can contain two methods: static
C #: a question about static and non-static,
With regard to the differences between static methods, variables, non-static methods, and variables, the great gods in the garden have long made many detailed summaries, I personally think the differences
The order of data initialization in a class is one of the questions that the interviewer likes very much, this article uses an example to introduce the Java sub-class, the parent class static code block, the field, the non-static code block, the
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacethe difference between static and non-static { Public classPerson { Public voidM1 () {Console.WriteLine ("I am a non-static method");
Reprint: http://blog.csdn.net/seattle1215/article/details/6657814
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Cash
{
Class Program
{
static void Main (string[] args)
{
(
When is the PHP static and non-static methods used separately?
Non-static methods are often used, but when should you use non-static methods?
Reply content:
When is the PHP static and non-static methods used separately?
Non-static methods are
The static keyword is used to modify properties, methods, which are called properties, methods as static properties, and static methods.
The static keyword declares that a property or method is related to a class and not to a particular instance
1 General class static member functions cannot call non-static member functions2 can a static member function call a constructor?The answer is yes, because the static member function does not have this pointer, the general static member function
must the internal class access the variables of the external class be final ?as Follows:Class A{int i = 3;public void Shout (){Class B{public void Shout1 (){System.out.println (i);}}b b=new B ();B.SHOUT1 ();}public static void main (String []
1. Static and non-static classes●. Static classes can only contain static members and static methods; otherwise, a compilation error is thrown;Non-static classes can contain non-static members and non-static methods.Static member and static method;●
Static methods that use the static modifier are class methods that belong to the entire class, and the code snippets in memory are allocated and loaded with the definition of the class, whereas non-static methods are methods that belong to a
C # static member1. Static members belong to the class and non-static members belong to the instance.2. Each time a class instance is created, a new storage block is allocated to non-static members in the memory.C # static method1. C # static
Declaring a member in a class as static is a member of a static member class, or static, or non-static, in general, a static member is a non-static member belonging to a class and is an instance object of a class. The following example code
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.