你可以相反的顺序在一个行的字符串使用LINQ或lambda表达式 [英] Can you reverse order a string in one line with LINQ or a LAMBDA expression
问题描述
这并不是说我会想实际使用(很多原因),但严格的好奇,我想知道是否有扭转秩序的一条线使用LINQ和/或lambda表达式的字符串的方法代码后,没有使用任何框架反向的方法。
Not that I would want to use this practically (for many reasons) but out of strict curiousity I would like to know if there is a way to reverse order a string using LINQ and/or LAMBDA expressions in one line of code, without utilising any framework "Reverse" methods.
例如
string value = "reverse me";
string reversedValue = (....);
和reversedValue将导致EM esrever
and reversedValue will result in "em esrever"
修改
显然是不切实际的问题/解决方案,我知道这一点,所以不必担心它的严格周围的LINQ / LAMBDA构建一个好奇的问题。
EDIT Clearly an impractical problem/solution I know this, so don't worry it's strictly a curiosity question around the LINQ/LAMBDA construct.
推荐答案
我不认为这只是为好玩起见实际用途:
I don't see a practical use for this but just for the sake of fun:
new string(Enumerable.Range(1, input.Length).Select(i => input[input.Length - i]).ToArray())
这篇关于你可以相反的顺序在一个行的字符串使用LINQ或lambda表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!