Usuário com melhor resposta
HELP! "Programa não possui um método "Main" estático adequado para um ponto de entrada"

Pergunta
-
Saudações! Pois bem, comecei a estudar programação recentemente (pelo C#), logo, desconheço alguns conceitos. Assim sendo, eu preciso de ajuda em um código que peguei como referencia, em que fica apontando esse erro -"Programa não possui um método "Main" estático adequado para um ponto de entrada"-, porém não sei exatamente onde e como corrigir.
Grato desde já!
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ExercisesProject.Exercises { class VigenereCipher { //static void Main(string[] args) public static void Run() { Console.WriteLine("VigenereCipher"); Console.WriteLine(); string clearText = "texttocipher"; Console.WriteLine("Original Text: " + clearText); Console.WriteLine(); List<char> alphabet = Enumerable.Range('a', 'z' - 'a' + 1) .Select(x => (char)x).ToList(); char[][] tabulaRecta = new char['z' - 'a' + 1][]; for (int i = 0; i < tabulaRecta.Length; i++) { tabulaRecta[i] = alphabet.ToArray(); var first = alphabet.First(); alphabet.Remove(first); alphabet.Insert(alphabet.Count, first); } string keyword = "alltech"; Console.WriteLine("Keyword: " + keyword); string cipherText = Cipher(clearText, tabulaRecta, keyword); Console.WriteLine("Ciphered Text: {0}", cipherText); string decipherText = Decipher(cipherText, tabulaRecta, keyword); Console.WriteLine("Deciphered Text: {0}", decipherText); Console.ReadKey(); } private static string GrowToTextSize(int length, string keyword) { string result = keyword; int idx = 0; while (result.Length < length) { result += keyword[idx++]; if (idx >= length) { idx = 0; } } return result; } private static char[][] TransposeMatrix(char[][] matrix) { char[][] result = new char[matrix[0].Length][]; for (int i = 0; i < result.Length; i++) { result[i] = new char[matrix.Length]; } for (int row = 0; row < matrix.Length; row++) { for (int col = 0; col < matrix[row].Length; col++) { result[col][row] = matrix[row][col]; } } return result; } private static int IndexOf(char[] array, char toFind) { int result = -1; for (int i = 0; i < array.Length; i++) { if (array[i] == toFind) { result = i; break; } } return result; } private static string Cipher( string clearText, char[][] tabulaRecta, string keyword) { string result = string.Empty; keyword = GrowToTextSize(clearText.Length, keyword); for (int i = 0; i < clearText.Length; i++) { int row = clearText[i] - 'a'; int col = keyword[i] - 'a'; result += tabulaRecta[row][col]; } return result; } private static string Decipher( string cipherText, char[][] tabulaRecta, string keyword) { string result = string.Empty; keyword = GrowToTextSize(cipherText.Length, keyword); tabulaRecta = TransposeMatrix(tabulaRecta); for (int i = 0; i < cipherText.Length; i++) { int row = keyword[i] - 'a'; int col = IndexOf(tabulaRecta[row], cipherText[i]); result += tabulaRecta[0][col]; } return result; } } }
Respostas
-
Isso está ao contrário:
//static void Main(string[] args) public static void Run()
Melhor ainda seria:
static int Main(string[] arg)
e retornar "0". Se o Main retorna inteiro, "0" significa "executado com sucesso".
No projeto, no Visual Studio ("Properties"), selecione esse método como start.
- Sugerido como Resposta SammuelMiranda sexta-feira, 27 de outubro de 2017 17:34
- Marcado como Resposta Filipe B CastroModerator segunda-feira, 30 de outubro de 2017 17:30
Todas as Respostas
-
Isso está ao contrário:
//static void Main(string[] args) public static void Run()
Melhor ainda seria:
static int Main(string[] arg)
e retornar "0". Se o Main retorna inteiro, "0" significa "executado com sucesso".
No projeto, no Visual Studio ("Properties"), selecione esse método como start.
- Sugerido como Resposta SammuelMiranda sexta-feira, 27 de outubro de 2017 17:34
- Marcado como Resposta Filipe B CastroModerator segunda-feira, 30 de outubro de 2017 17:30
-
Boa tarde,
Por falta de retorno essa thread está encerrada.
Se necessário, favor abrir uma nova thread.
Atenciosamente,Filipe B de Castro
Esse conteúdo é fornecido sem garantias de qualquer tipo, seja expressa ou implícita
MSDN Community Support
Por favor, lembre-se de Marcar como Resposta as postagens que resolveram o seu problema. Essa é uma maneira comum de reconhecer aqueles que o ajudaram e fazer com que seja mais fácil para os outros visitantes encontrarem a resolução mais tarde.