Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Saturday, April 22, 2017 5:36 PM | 1 vote
Class Program
{ Main ()
{
//some code
Program p = new Program();
p.TranslateMorse();
} public string TranslateMorse()
{
string input = Console.ReadLine();
string output = string.Empty;
char[] splitInputString = input.Trim().ToLower().ToCharArray();
foreach (char c in splitInputString)
{
int index = Array.IndexOf(english, c);
output += ' ' + morse[index];
}
// string[] outputarray = new string[] { output };
using (System.IO.StreamWriter file =
new System.IO.StreamWriter(path4, true))
{
file.WriteLine(output);
}
//File.WriteAllLines(path4, outputarray);
Console.WriteLine(output);
Console.ReadKey(false);
}
}
}
Hi there,
i am trying to convert english text to morse code. and have written this method.
but when compiling this error is shown ie; "the modifier public is not valid for this item" .
i'm a beginner in programming & couldnt solve this issue.. could any one pls tell me how to solve this error .
many thanks,
All replies (3)
Saturday, April 22, 2017 8:23 PM | 2 votes
declare Main as
static void Main()
Monday, April 24, 2017 6:46 AM | 1 vote
Hi friend,
I agree with Wojciech, you could have a try, and I also edited your coded a little bit, just hope it's helpful.
public static void Main(string[] args)
{
TranslateMorse();
string TranslateMorse()
{
string input = Console.ReadLine();
string output = string.Empty;
char[] splitInputString = input.Trim().ToLower().ToCharArray();
foreach (char c in splitInputString)
{
int index = Array.IndexOf(english, c);
output += ' ' + morse[index];
}
// string[] outputarray = new string[] { output };
using (System.IO.StreamWriter file =
new System.IO.StreamWriter(path4, true))
{
file.WriteLine(output);
}
//File.WriteAllLines(path4, outputarray);
Console.WriteLine(output);
Console.ReadKey(false);
return null;
}
}
Best regards,
Fletch
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Tuesday, April 25, 2017 1:24 AM
Hi friend,
Please help to mark a reply as answer if it's okay for you.
Thanks.
Best regards,
Fletch
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].