Skip to main content
added 90 characters in body
Source Link
Justin Niessner
  • 245.9k
  • 40
  • 416
  • 546

Generally, it is a good idea to use the most generic solution possible.

DemoEnum.TryParse("input", out value)

Is translated intothe same call as (you're just making the static call from an inherited class rather than the base class):

Enum.TryParse<DemoEnum>("input", out value)

Using the base class qualifier (Enum) instead of your specific enum (DemoEnum) would insulate you from possible side effects of changing DemoEnum in the future. The reality is that you're really only going to run into issues if you change DemoEnum to a class without changing the name.

This is generally a larger issue when using classes (and ReSharper will give the same guidance in those situations).

Generally, it is a good idea to use the most generic solution possible.

DemoEnum.TryParse("input", out value)

Is translated into

Enum.TryParse<DemoEnum>("input", out value)

Using the base class qualifier (Enum) instead of your specific enum (DemoEnum) would insulate you from possible side effects of changing DemoEnum in the future. The reality is that you're really only going to run into issues if you change DemoEnum to a class without changing the name.

This is generally a larger issue when using classes (and ReSharper will give the same guidance in those situations).

Generally, it is a good idea to use the most generic solution possible.

DemoEnum.TryParse("input", out value)

Is the same call as (you're just making the static call from an inherited class rather than the base class):

Enum.TryParse<DemoEnum>("input", out value)

Using the base class qualifier (Enum) instead of your specific enum (DemoEnum) would insulate you from possible side effects of changing DemoEnum in the future. The reality is that you're really only going to run into issues if you change DemoEnum to a class without changing the name.

This is generally a larger issue when using classes (and ReSharper will give the same guidance in those situations).

added 371 characters in body
Source Link
Justin Niessner
  • 245.9k
  • 40
  • 416
  • 546

Generally, it is a good idea to use the most generic solution possible.

DemoEnum.TryParse("input", out value)

Is translated into

Enum.TryParse<DemoEnum>("input", out value)

Using the base class qualifier (Enum) instead of your specific enum (DemoEnum) would insulate you from possible side effects of changing DemoEnum in the future. The reality is that you're really only going to run into issues if you change DemoEnum to a class without changing the name.

This is generally a larger issue when using classes (and ReSharper will give the same guidance in those situations).

Generally, it is a good idea to use the most generic solution possible. Using the base class qualifier (Enum) instead of your specific enum (DemoEnum) would insulate you from possible side effects of changing DemoEnum in the future.

Generally, it is a good idea to use the most generic solution possible.

DemoEnum.TryParse("input", out value)

Is translated into

Enum.TryParse<DemoEnum>("input", out value)

Using the base class qualifier (Enum) instead of your specific enum (DemoEnum) would insulate you from possible side effects of changing DemoEnum in the future. The reality is that you're really only going to run into issues if you change DemoEnum to a class without changing the name.

This is generally a larger issue when using classes (and ReSharper will give the same guidance in those situations).

Source Link
Justin Niessner
  • 245.9k
  • 40
  • 416
  • 546

Generally, it is a good idea to use the most generic solution possible. Using the base class qualifier (Enum) instead of your specific enum (DemoEnum) would insulate you from possible side effects of changing DemoEnum in the future.