using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Program
{
class Program
{
public static string *GetExtension*(string cale) //GetExtension is an error
{
string fisier, extensie;
cale = @"D:\dir1\dir2\";
fisier = @"D:\dir1\dir2\fisier.txt";
extensie = Path.GetExtension(fisier);
System.Console.WriteLine("Extensie: {0} returneaza {1}", fisier, extensie);
extensie = Path.GetExtension(cale);
System.Console.WriteLine("Extensie: {0} returneaza {1}", fisier, extensie);
}
}
}
I apologize for this amateur post.
I don’t understand the error "Program.Program.GetExtension(string)': not all code paths return a value"
Can anyone tell me what have I done wrong, please?
(oh and fisier means file, cale mean path and extensie mean extension in my language).
Thanks in Advance.
The function is supposed to return a string but you have no return statement
add
before the first
}alternatively if you aren’t wanting a return value and are just wanting the console.writelines simply change
public static stringto bepublic static voidand then you won’t need a return value