おはようございます、単純なばかげた質問です。同様の問題がある投稿を見つけましたが、読んでもエラーは解決しません。
メソッド内の foreach ループから戻り値を取得できません
メソッド: meth1 meth2 ect....すべてが値を返しますが、現時点ではエラーが発生しています
各メソッドの「エラー 1 'Proj5.Program.meth1(int)': すべてのコード パスが値を返すわけではありません」。
私の論理的な推測は、ループ内で値が表示されないことです?? ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Proj5
{
class Program
{
static void Main()
{
for (int i = 1; i < 101; i++)
{
if (i == 3 || 0 == (i % 3) || 0 == (i % 5) || i == 5)
{
Console.Write(meth1(i));
Console.Write(meth2(i));
Console.Write(meth3(i));
Console.Write(meth4(i));
}
else
{
Console.Write(TheInt(i));
}
}
Console.ReadLine();
}
static string meth1(int i)
{
string f = "fuzz";
if (i == 3)
{
return f;
}
}
static string meth2(int i)
{
string f = "fuzz";
if (0 == (i % 3))
{
return f;
}
}
static string meth3(int i)
{
string b = "buzz";
if (i == 5)
{
return b;
}
}
static string meth4(int i)
{
string b = "buzz";
if (0 == (i % 5))
{
return b;
}
}
static int TheInt(int i)
{
return i;
}
}
}