C # enum scope. visible only with function

in C #, is it possible to declare Enum, which is only displayed inside the function, where will I use it?

+3
source share
3 answers

Enumerations have the same rules as classes. You cannot declare them inside a function, although you can declare them private to a class:

public class Foo {
  private enum Bar { A, B, C }
}
+3
source

No. An enumeration must be declared in a namespace or class, so it will always have scope outside the function itself.

+3
source

With the help classyou can do. I do not think that you can make it visible only for a specific one function.

0
source

Source: https://habr.com/ru/post/1776381/


All Articles