Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using static System.Console;
- namespace Ref_Example
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool differentbool = false; //MUST BE DECALRED :: Note that it is assigned to false
- test(ref differentbool); //Grab bool from test
- WriteLine(differentbool); //returns true instead of false
- bool differentbool2 = false; // Note that it is assigned to false
- yo(differentbool2); //sent bool to yo
- WriteLine(differentbool2); //returns false (no reference, no idea what mybool is in yo)
- }
- static void test(ref bool mybool)
- {
- mybool = true;
- }
- static void yo(bool mybool)
- {
- mybool = true;
- }
- }
- }
Add Comment
Please, Sign In to add comment