JasperHuyghe

Untitled

Mar 8th, 2023
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. program.cs
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Oef2Omkeren
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             Business w1 = new Business();
  15.             Console.WriteLine("Geef een woord");
  16.             string naam = Console.ReadLine();
  17.             Console.ForegroundColor = ConsoleColor.Blue;
  18.             string output = w1.Omkeren(naam);
  19.             Console.WriteLine(output);
  20.             Console.WriteLine();
  21.             if (output == naam)
  22.             {
  23.                 Console.ForegroundColor = ConsoleColor.Cyan;
  24.                 Console.WriteLine("Je hebt een palindroom");
  25.             }
  26.             Console.ReadLine();
  27.  
  28.  
  29.         }
  30.     }
  31. }
  32. business.cs
  33. using System;
  34. using System.Collections.Generic;
  35. using System.Linq;
  36. using System.Text;
  37. using System.Threading.Tasks;
  38.  
  39. namespace Oef2Omkeren
  40. {
  41.     class Business
  42.     {
  43.         public string Omkeren(string pinvoer)
  44.         {
  45.             //return new string(pwoord.Reverse().ToArray());
  46.             string resultaat = "";
  47.             for (int teller = pinvoer.Length - 1; teller >= 0; teller--)
  48.             {
  49.                 resultaat += pinvoer[teller];
  50.                
  51.             }
  52.             return resultaat;
  53.         }
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment