Skip to content

Commit 4d8b5bd

Browse files
committed
add implicit from ndarray to string when rank is 0.
1 parent aa570de commit 4d8b5bd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/NumSharp.Core/Casting/Implicit/NdArray.Implicit.ValueTypes.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ namespace NumSharp.Core
2929
{
3030
public partial class NDArray
3131
{
32+
public static implicit operator string(NDArray nd)
33+
{
34+
if (nd.ndim > 0)
35+
throw new IncorrectShapeException();
36+
37+
return nd.Data<string>(0);
38+
}
39+
3240
public static implicit operator NDArray(float d)
3341
{
3442
var ndArray = new NDArray(typeof(float), new int[0]);

0 commit comments

Comments
 (0)