Pass in an enum as a method parameter

The Solution to Pass in an enum as a method parameter is

Change the signature of the CreateFile method to expect a SupportedPermissions value instead of plain Enum.

public string CreateFile(string id, string name, string description, SupportedPermissions supportedPermissions)
    file = new File
        Name = name,
        Id = id,
        Description = description,
        SupportedPermissions = supportedPermissions

    return file.Id;

Then when you call your method you pass the SupportedPermissions value to your method

  var basicFile = CreateFile(myId, myName, myDescription, SupportedPermissions.basic);

~ Answered on 2013-09-23 09:08:54

Most Viewed Questions: