Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace CsharpCourse
- {
- internal class Program
- {
- // ref
- // must be initialized
- // out
- // may not be initialized
- // must be assigned to a value in all paths in the method
- static void Main(string[] args)
- {
- int x = 2;
- bool IsEven;
- DoubleOut(x, out IsEven);
- bool ref_IsEven = false;
- DoubleRef(x, ref ref_IsEven);
- }
- static void DoubleOut(int x, out bool IsEven)
- {
- if (x % 2 == 0)
- {
- IsEven = true;
- return;
- }
- IsEven = false;
- return;
- }
- static void DoubleRef(int x, ref bool IsEven)
- {
- if (x % 2 == 0)
- {
- IsEven = true;
- return;
- }
- // IsEven = false;
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement