Results 1 to 9 of 9

Thread: [RESOLVED] [2.0] "Not all code paths return a value" error. how to fix this compilation error..

Threaded View

  1. #2
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Post Re: [2.0] "Not all code paths return a value" error. how to fix this compilation error..

    Your example always returns on the first iteration of the loop - obviously not what you want...
    The error is there because if there is nothing contained in ADGroups, then no return statement is executed.

    You want something like the following:

    VB Code:
    1. public static bool IsMember(List<string> ADGroups)
    2. {
    3.    System.Security.Principal.IPrincipal User1;
    4.    User1 = System.Web.HttpContext.Current.User;
    5.  
    6.    foreach (string xx in ADGroups)
    7.    {
    8.       string sADRole = "fhlbsf-i.com\\"+ xx.ToString();
    9.       if ((User1.IsInRole(sADRole) == true))
    10.       {
    11.          return true;
    12.       }
    13.    }
    14.    return false;
    15. }
    Last edited by David Anton; Sep 6th, 2006 at 10:02 AM. Reason: formatting
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width