Hi,
how can I use this code win C# Console application. I am total greenhorn in writeing apps.
I need to create app that converts alphabet to morse code.
In class we use visual studio 2015. We are crating app in C# console applications for windows.
Our apps templates starts with:
Program I found on Morse Code Implementation - GeeksforGeeks
Is:
My question is:
How can I implement this code to work with my tamplate. I need to create app tahat is useing switch case for convert alphabet to morse.
Thanks and have a nice day.
how can I use this code win C# Console application. I am total greenhorn in writeing apps.
I need to create app that converts alphabet to morse code.
In class we use visual studio 2015. We are crating app in C# console applications for windows.
Our apps templates starts with:
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
}
}
}
Program I found on Morse Code Implementation - GeeksforGeeks
Is:
C#:
// C# program to demonstrate Morse code
using System;
class GFG
{
// function to encode a alphabet as
// Morse code
static string morseEncode(char x)
{
// refer to the Morse table
// image attached in the article
switch (x)
{
case 'a':
return ".-";
case 'b':
return "-...";
case 'c':
return "-.-.";
case 'd':
return "-..";
case 'e':
return ".";
case 'f':
return "..-.";
case 'g':
return "--.";
case 'h':
return "....";
case 'i':
return "..";
case 'j':
return ".---";
case 'k':
return "-.-";
case 'l':
return ".-..";
case 'm':
return "--";
case 'n':
return "-.";
case 'o':
return "---";
case 'p':
return ".--.";
case 'q':
return "--.-";
case 'r':
return ".-.";
case 's':
return "...";
case 't':
return "-";
case 'u':
return "..-";
case 'v':
return "...-";
case 'w':
return ".--";
case 'x':
return "-..-";
case 'y':
return "-.--";
// for space
case 'z':
return "--..";
}
return "";
}
static void morseCode(string s)
{
// character by character print
// Morse code
for (int i = 0;i<s.Length; i++)
Console.Write(morseEncode(s[i]));
Console.WriteLine();
}
// Driver code
public static void Main ()
{
string s = "geeksforgeeks";
morseCode(s);
}
}
// This code is contributed by vt_m.
My question is:
How can I implement this code to work with my tamplate. I need to create app tahat is useing switch case for convert alphabet to morse.
Thanks and have a nice day.