torno torno - 18 days ago 4
C# Question

Parsing FQN of enum constant to enum constant w/o splitting the string

Trying to parse an commandline argument ( 'MyNameSpace.MyEnumClassName.MyConstantName') in order to get the constant.

Is this possible without extracting the EnumClassName? I know that I could get the constant with

Type.GetType(...);
Enum.Parse(...)


But is there a direct way?

Background:
This argument can be used for different things. There can be a fqn of a class, a constant, ... I know it's not kind of 'clean', but that`s not part of this question.

Answer

As there seems to be no direct way, I close this question with the answer "no".