Advertisement
karlakmkj

Fixing return errors

Nov 18th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ReturnErrors
  4. {
  5.   class Program
  6.   {
  7.     static void Main(string[] args)
  8.     {
  9.       Console.WriteLine(DecoratePlanet("Mars"));
  10.       Console.WriteLine("Is Pluto really a dwarf...?");
  11.       Console.WriteLine(IsPlutoADwarf());
  12.       Console.WriteLine("Then how many planets are there in the galaxy...?");
  13.       Console.WriteLine(CountThePlanets());
  14.     }
  15.    
  16.     static string DecoratePlanet(string planet)
  17.     {
  18.        return $"*..*..* Welcome to {planet} *..*..*";
  19.     }
  20.    
  21.     //takes no arguments
  22.     //not to create variable and use them before declaration
  23.     static bool IsPlutoADwarf()
  24.     {
  25.       return true;
  26.     }
  27.    
  28.     static string CountThePlanets()
  29.     {
  30.       return "8 planets, usually";
  31.     }
  32.   }
  33. }
  34.  
  35. /*
  36. For IsPlutoADwarf() method:
  37. Steps is to
  38. 1. define a variable
  39. 2. set a value to it (can be in the same line as step 1)
  40. 3. then return its value.
  41.  
  42. DO NOT do all that in just one line of code.
  43. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement