What would be the difference between fields and variables in C #?

2

What would be the difference between fields and variables in C #?

    
asked by anonymous 26.10.2018 / 05:01

1 answer

3

I've already shown you what a variable .

The field is a member of a data structure, that is, a type such as struct or class that contains a state, that is, a value. This value can be constant or variable. Therefore field is a specific way to have a variable.

Then the field will be present in types, in the case of static fields, or will be in instances (which you already asked what is ).

It makes no difference whether the field visibility is private, protected, internal, or public.

If you want to know about the difference between the local variable and the instance variable (the question is not this, but in any case ...) already was answered .

Some people confuse attribute with field . The programming languages have field and not attribute, at least in this context. Attribute is another for languages. Unfortunately UML uses this term for the field, and people misunderstand and then mix concepts in different contexts, write articles, answers and even books in the wrong way.

On the other hand, you might want to know about the Difference between "Attribute" and "Instance Variable . / p>

It should also be of interest: What's the difference in instantiating, initializing, and declaring a variable? . You may also want to know Public field X property . And also Difference between "Attribute" and "Instance Variable" . As I said earlier if you search the site and follow links you will find several very good content to learn these concepts.

    
26.10.2018 / 13:21