Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Jumble a string using LINQ

, 6 May 2011
Rate this:
Please Sign up or sign in to vote.
Using LINQ to create a jumbled string.
I came across this question in an interview. The question was a logical one. I have two variables like this:
string value1 = "Demo";
string value2 = "eoDm";
Write code to find set value in value2 as the jumbled word of value1. And here is how to do it:
string value1 = "Demo";
string value2 = "eoDm";
var  valueordered1 = value1.ToCharArray().OrderBy(n => n);
var valueordered2 = value2.ToCharArray().OrderBy(n => n);
Console.WriteLine( valueordered1.SequenceEqual(valueordered2));
Console.ReadLine();

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Steven.Pinto2000

United States United States
No Biography provided
Group type: Social Group (No members)



Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 6 May 2011
Article Copyright 2011 by Steven.Pinto2000
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid