Passing enum values to a function in PowerShell

后端 未结 4 1860
悲&欢浪女
悲&欢浪女 2021-02-19 20:52

I have a function accepting an enum value as parameter. As an example, consider something like:

(PS) > function IsItFriday([System.DayOfWeek] $dayOfWeek) { 
          


        
4条回答
  •  盖世英雄少女心
    2021-02-19 21:41

    To avoid the error put the enum value in parenthesis:

    PS > IsItFriday ([System.DayOfWeek]::Monday)  
    no
    
    PS > IsItFriday ([System.DayOfWeek]::Friday)  
    yes
    

提交回复
热议问题