I try to Reverse my string but I get to following error
string str = word.Reverse();
error:
cannot convert from 'System.Collections.Generic.IEnumerable' to 'string'
anyone know what should I need to do ?
I try to Reverse my string but I get to following error
string str = word.Reverse();
error:
cannot convert from 'System.Collections.Generic.IEnumerable' to 'string'
anyone know what should I need to do ?
You should build a new string.
string str = new string(word.Reverse().ToArray());
Calling ToArray()
on an IEnumerable<T>
will convert it to T[]
.
string
has a constructor which get array of character and constructs a string.
You should join characters together to make new string.
string str = string.Join(string.Empty, word.Reverse());