{"id":17838,"date":"2008-12-14T08:03:35","date_gmt":"2008-12-14T16:03:35","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=17838"},"modified":"2019-06-07T10:55:05","modified_gmt":"2019-06-07T18:55:05","slug":"what-the-heck-is-an-enum","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/what-the-heck-is-an-enum\/","title":{"rendered":"What the Heck is an ENUM?"},"content":{"rendered":"<p>In my latest post <a href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2008\/12\/13\/explore-your-environment.aspx\">Explore your [Environment]<\/a> I said the following:<\/p>\n<p><font size=\"2\"><font face=\"Consolas\"><font color=\"#0000ff\">PS&gt; <strong>[System.Environment+SpecialFolder]<\/strong><\/font><\/font><\/font><\/p>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Consolas\">IsPublic IsSerial Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BaseType      <br \/>&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8211;       <br \/>False&#160;&#160;&#160; True&#160;&#160;&#160;&#160; SpecialFolder&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>System.Enum<\/strong><\/font><\/p>\n<p><font color=\"#0000ff\" size=\"2\" face=\"con\">Notice that it is an ENUM.&#160; The great things about ENUMS is that when you specify an invalid value &#8211; it tells you what the valid values are:<\/font><\/p>\n<p><font color=\"#0000ff\" size=\"2\"><\/font><\/p>\n<p>One of the comments made me realize that a lot of people will have no idea what I&#8217;m talking about so I thought I would spend a minute explaining.&#160; <\/p>\n<p>ENUM is short for ENUMERATION.&#160; In .NET, ENUM is a base class for a set of named constants.&#160; You can think of it as a set of strings (that is not entirely accurate but for our purposes &#8211; it is a perfect explanation.&#160;&#160; So when you see that something takes an ENUM, what it means is that it doesn&#8217;t just take any old string &#8211; it takes one of a set of strings.&#160; <\/p>\n<p>What is that set of string? &#8211; That&#8217;s the beauty of an ENUM, it will tell it.&#160; All you have to do is to provide a wrong value and it will tell you what the right values are.<\/p>\n<p><font color=\"#000000\" size=\"2\" face=\"con\">Enjoy<\/font><\/p>\n<p>Jeffrey Snover [MSFT]   <br \/>Windows Management Partner Architect    <br \/>Visit the Windows PowerShell Team blog at:&#160;&#160;&#160; <a href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/a>    <br \/>Visit the Windows PowerShell ScriptCenter at:&#160; <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my latest post Explore your [Environment] I said the following: PS&gt; [System.Environment+SpecialFolder] IsPublic IsSerial Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BaseType &#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8211; False&#160;&#160;&#160; True&#160;&#160;&#160;&#160; SpecialFolder&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.Enum Notice that it is an ENUM.&#160; The great things about ENUMS is that when you specify an invalid value &#8211; it tells you what the valid values are: One of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[158,4,325],"class_list":["post-17838","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-enum","tag-howto","tag-system-environment"],"acf":[],"blog_post_summary":"<p>In my latest post Explore your [Environment] I said the following: PS&gt; [System.Environment+SpecialFolder] IsPublic IsSerial Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BaseType &#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8211; False&#160;&#160;&#160; True&#160;&#160;&#160;&#160; SpecialFolder&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.Enum Notice that it is an ENUM.&#160; The great things about ENUMS is that when you specify an invalid value &#8211; it tells you what the valid values are: One of [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=17838"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17838\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=17838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=17838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=17838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}