Click here to Skip to main content
12,697,311 members (28,316 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

3.2K views
Posted

Jumble a string using LINQ

, 6 May 2011 CPOL
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)



You may also be interested in...

Pro
Pro

Comments and Discussions

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