I am attempting to have the for statement iterate and increase the number i from 0 to 100.
This will be displayed on the screen.
My issue is not quite understanding what I want to return in the method (not Main) but if I need to return anything.
I don’t want to return a int. I don’t think I have a string to return as I want it to perform a function not return a value. I think I am messing up method types.
I want the method to simply go through the if statements and if a parameter matches then display the result on screen, if not move on to bottom and start again from for statement.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Project5
{
class Program
{
int i = 0;
static void Main(int i)
{
do
{
for (i = 0; i < 101; i++)
{
Words();
}
} while (i < 101);
Console.ReadLine();
}
static string Words (int i) //<---Here I think I am using the incorrect method type
{//Which then screws up the method when it is called above. I have been going
//through method types but dont see anything that when called just perform a
//function and displays results.
string f = "Word1";
string b = "Word2";
if (i == 3)
{
Console.Write(f);
if (i == 5)
{
Console.Write(b);
if (0 == (i % 3))
{
Console.Write(f);
if (0 == i % 5)
{
Console.Write(b);
}
else
{
Console.WriteLine(i);
}
}
}
}
}
}
}
Change
to
then it doesn’t have to return anything
Also you should probably remove the do loop as it is redundant, the for loop should be doing what you want (I think).