Advertisement
karlakmkj

Using out keyword

Nov 18th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using System;
  2.  
  3. namespace OutErrors
  4. {
  5.   class Program
  6.   {
  7.     static void Main(string[] args)
  8.     {
  9.       string statement = "GARRRR";
  10.       bool marker;
  11.       string murmur = Whisper(statement,out marker); //when call method should also use out keyword
  12.       Console.WriteLine(murmur);
  13.     }  
  14.    
  15.     static string Whisper(string phrase, out bool wasWhisperCalled)
  16.     {
  17.       wasWhisperCalled = true; //out parameter must be assigned a value before the return statement
  18.       return phrase.ToLower();
  19.     }
  20.   }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement