c# - Not All Code Path Return Value in Func<> Generic Type Delegate -


i new generic type delegates , try implement func<> generic type delegate

i developing winform application in try save file save function returns me bool (true/false). know simple implement without generic delegate want implement generic delegate code

public bool save( string filename, saveflags options) {     if (filename == null) throw new argumentnullexception("file");     using (filestream fs = file.create(filename))     {         func<string, saveflags, bool> func2 = (filestream, opt) => save(fs , options);        **// should need return**       } }  private bool save(stream istream, saveflags options) {    **//some operation perform , return true or false**  } 

i know whatever last out parameter of func<> become return type of func<> i.e. return func<>.

so how can handle error "not code path return value"

first up, looking @ infinite recursion. lambda parameter names, intended attach overload accepting stream. func<string, saveflags, bool> means you're going overload accepting string instead.

next, if delegate takes parameters, don't need capture parameters of current function call. lambda isn't helpful @ all.

taking account:

public bool save( string filename, saveflags options) {     if (filename == null) throw new argumentnullexception("file");     func<stream, saveflags, bool> func2 = save;     using (filestream fs = file.create(filename))     {         return func2(fs, options);     } } 

Comments