Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Score
- {
- using System;
- public class RefExample
- {
- public static void Main()
- {
- int score = 0;
- // no ref
- //IncreaseScoreNoRef(score);
- //Console.WriteLine(score);
- // ref
- IncreaseScoreRef(ref score);
- Console.WriteLine(score);
- }
- public static void IncreaseScoreRef(ref int score)
- {
- score += 10;
- }
- public static void IncreaseScoreNoRef(int score)
- {
- score += 10;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement