1
I am assembling a program in C# and created a method called Supply that receives an array called a number and returns the same. The idea is that the supply function creates random values, fill in the vector and return it filled to the main function (I haven’t done this value creation part yet), the function is being called in the Main
.
The problem: is accusing that the line in which I call the method in the Main
is wrong, I’ve tried many ways, but so far nothing has worked.
I don’t know if I declared the line right:
ERROR LINE - number = Supply(number);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
/*---------------------------------------------------
Métodos do programa
---------------------------------------------------*/
//Método de fornecimento de numeros
int[] Fornecimento(int[] numero)
{
int opcao;
//apresentação do tipo de opcao
Console.Clear();
Console.Write("*****************************************************************");
Console.Write("\n*\t\t\t\t\t\t\t\t*");
Console.Write("\n*\t\tFORNECIMENTO DE NUMEROS\t\t\t\t*");
Console.Write("\n*\t\t\t\t\t\t\t\t*");
Console.Write("\n*****************************************************************");
Console.Write("\n\n\tO que deseja fazer: \n\n\t=>1-Fornecer os numeros \n\t=>2-Gerar numeros automaticamente \n\n\tEscolha uma opcao: ");
opcao = Convert.ToInt32(Console.ReadLine());
if (opcao == 1)
{
}
return (numero);
}
/*---------------------------------------------------
Método principal do programa
---------------------------------------------------*/
static void Main(string[] args)
{
//declaração de variáveis
int[] numero = new int[500000];
int retorno = 1, tipo = 0;
while (retorno == 1)
{
//comando limpa a tela
Console.Clear();
//apresentação do programa
Console.Write("*****************************************************************");
Console.Write("\n*\t\t\t\t\t\t\t\t*");
Console.Write("\n*\t\t\tALGORITMO DE ORDENACAO\t\t\t*");
Console.Write("\n*\t\t\t\t\t\t\t\t*");
Console.Write("\n*****************************************************************");
//menu de escolha do tipo de algoritmo de ordenação(loop repete até que um tipo válido seja inserido)
while ((tipo != 1) && (tipo != 2) && (tipo != 3))
{
Console.Write("\n\n\tQue tipo de algoritmo deseja utilizar: \n\n\t1-Inserction sort \n\t2-Selection sort \n\t3-Bubble sort \n\n\tEscolha uma opção=> ");
tipo = Convert.ToInt32(Console.ReadLine());
}
numero = Fornecimento(numero);
}
retorno++;
//Environment.Exit(exitCode);
Console.ReadKey();
}
}
}
Say what’s wrong, what’s the line.
– Maniero
'number = Supply(number);'
– Sarah
Your
retorno++;
is out of thewhile
so it doesn’t work.– Tiedt Tech
What’s the mistake??
– Maniero
tidied but continues to signal error in the @Marlon Tiedt method call
– Sarah
There I got it! had to put Static in the method statement
– Sarah