This repository has been archived by the owner on Aug 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae5f982
commit 6a6f45d
Showing
4 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Strinum | ||
|
||
Quick and easy conversion between enum and strings using source generator. | ||
|
||
## Features | ||
|
||
### Convert Enum To String | ||
Convert an enum to a string representation, using the `StringEnum.ToString` method. The output can be customized | ||
using the `StringEnumAttribute` class. | ||
|
||
```csharp | ||
enum MyEnum | ||
{ | ||
ValueOne, | ||
[StringEnum("Value 2")] ValueTwo | ||
} | ||
|
||
|
||
string value = StringEnum.ToString(MyEnum.Value); | ||
``` | ||
|
||
### Convert String To Enum | ||
Convert a string to an enum representation, using the `StringEnum.ToEnum` method. The method returns a null in case | ||
that the string does not match any enum member. | ||
|
||
```csharp | ||
MyEnum? value = StringEnum.ToEnum<MyEnum>("Value"); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes