| |

VerySource

 Forgot password?
 Register
Search
View: 714|Reply: 6

Novice for help! !! !! What is a field in C #?

[Copy link]

3

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-1-23 12:00:02
| Show all posts |Read mode
What is a field in C #? What is the difference from member variables? ? ? ?
Reply

Use magic Report

0

Threads

56

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-2-6 20:45:02
| Show all posts
Fields are equivalent to data members in C ++. Generally declared as private or protected, and then exposed as attributes.
Reply

Use magic Report

3

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

 Author| Post time: 2020-2-6 22:00:01
| Show all posts
What's the syntax like?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-7 00:45:01
| Show all posts
Like ordinary members, but the concept of attributes is added in C #. Definitions of attributes are found in many books.
Go to Xunlei (www.xunlei.com) and search for "c # book", there are many tutorials.
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-2-14 16:15:02
| Show all posts
Adding a field to the class designer, I feel that it has the same effect as a member variable.
Reply

Use magic Report

0

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-17 14:30:01
| Show all posts
In fact, there are no essential differences between attributes, fields, and member variables.
Fields can also be declared as public, readonly, or other
However, attributes generally add an access restriction on the basis of the field and can also make the field a smart field.You can do some extra things when getting or setting the field value:
private int t;
public int T
{
    set {
        if (value .... // determine if value meets certain conditions
        {
            T = value;
        }
        else ....
    }
    get {...}
}
Reply

Use magic Report

0

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-17 15:30:01
| Show all posts
Hehe, wrong
Is t = value; not uppercase T
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list