| |

VerySource

 Forgot password?
 Register
Search
Author: yhb1224yhb

In C #, how to automatically generate an increasing number of natural numbers, and only add and not decrease?

[Copy link]

0

Threads

26

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-5-26 17:45:01
| Show all posts
Well, there is still a lack of single mode control, so it is more perfect
Reply

Use magic Report

0

Threads

38

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-5-27 11:30:02
| Show all posts
The volatile keyword should be added to indicate that it can be modified by concurrent threads
public sealed class Sequence {
    private static volatile int num = 0;
    public static int Next () {
       return ++ num;
    }
}
Reply

Use magic Report

0

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-6-11 15:15:01
| Show all posts
There are so many ways.
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