diff --git a/Directory.Packages.props b/Directory.Packages.props
index 04d12ca..bca5099 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -8,7 +8,7 @@
-
+
diff --git a/PowerKit.Tests/StringExtensionsTests.cs b/PowerKit.Tests/StringExtensionsTests.cs
index a60e97a..a35e27b 100644
--- a/PowerKit.Tests/StringExtensionsTests.cs
+++ b/PowerKit.Tests/StringExtensionsTests.cs
@@ -84,4 +84,14 @@ public void ToSnakeCase_Test()
"hello".ToSnakeCase().Should().Be("hello");
"".ToSnakeCase().Should().Be("");
}
+
+ [Fact]
+ public void Reverse_Test()
+ {
+ // Act & assert
+ "hello".Reverse().Should().Be("olleh");
+ "abcde".Reverse().Should().Be("edcba");
+ "a".Reverse().Should().Be("a");
+ "".Reverse().Should().Be("");
+ }
}
diff --git a/PowerKit/Extensions/StringExtensions.cs b/PowerKit/Extensions/StringExtensions.cs
index 101fe1c..c79db84 100644
--- a/PowerKit/Extensions/StringExtensions.cs
+++ b/PowerKit/Extensions/StringExtensions.cs
@@ -97,5 +97,28 @@ public string SeparateWords(char separator)
/// Converts the PascalCase string to snake_case (e.g., "FooBar" → "foo_bar").
///
public string ToSnakeCase() => str.SeparateWords('_').ToLowerInvariant();
+
+ ///
+ /// Returns the string with the characters in reverse order.
+ ///
+ public string Reverse()
+ {
+ if (str.Length <= 1)
+ {
+ return str;
+ }
+
+ return string.Create(
+ str.Length,
+ str,
+ static (chars, source) =>
+ {
+ for (var i = 0; i < source.Length; i++)
+ {
+ chars[i] = source[source.Length - 1 - i];
+ }
+ }
+ );
+ }
}
}