I have made a function that in my opinion will always return a value, but the function still says
All code paths does not return a value
Am I missing something?
public static bool CheckIfSignatureAlreadySignedByUser(SPSite site, SPWeb web, int RowID) { RevertToAppPool revert = new RevertToAppPool(); try { revert.UseAppPoolIdentity(); string dbConnectionString = site.WebApplication.Properties["dbConnection"].ToString(); using (dbDWDataContext dataContext = new dbDWDataContext(dbConnectionString)) { var signatures = dataContext.CM_Signatures.Where(c => c.ParagraphID == RowID).ToList(); if (signatures.Any()) { foreach (var sig in signatures) { if (sig.LoginName.ToLower() == web.CurrentUser.LoginName.ToLower()) { return false; } else return true; } } else { return true; } } } catch (Exception error) { SEPUtilities.WriteErrorToLog("Error in DWUtilities.AddSignature: {0}", error.ToString()); return false; } finally { revert.ReturnToImpersonatingCurrentUser(); } }
foreachand thenif elsethat both return from method? your foreach is useless i think. it doesnt make sense because it will always return from first iteration.