Code2night
  • Home
  • Guest Posts
  • Tutorial
  • Languages
    • Angular
    • C
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
  • Register
  • Login
  1. Home
  2. Blogpost

How to shuffle list in c#

Date- May 14,2022

6180

C#Net AspNet

For ordering a list to specific order we use OrderBy but in some case we need the list to be ordered differently every time we try to access the list. In that case order by becomes useless as we don't want to follow any specific order. So for that purpose we use Random class like this 


List<Author> authors = new List<Author>  
{  
    new Author { Name = "Code", Book = "c# Programming", Price = 59.95 },  
    new Author { Name = "Code2Night", Book = "Shuffle", Price = 69.95 },  
    new Author { Name = "Blogs", Book = "Lists", Price = 79.95 }  
};   

var rnd = new Random();
authors = authors.OrderBy(item => rnd.Next()).ToList();

So, here we will use Random() for generating random order every time and which will shuffle the list every time you will try to access the data. This is how to shuffe list in c#.

S
Shubham Batra
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

How to refund payment using Paypal in Asp.Net MVC
Jan 30, 2024
Integrate Stripe Payment Gateway In ASP.NET Core 8.0
Nov 23, 2023
How to get fcm server key
Nov 23, 2023
How to Convert Text to Speech in Asp.Net
Nov 06, 2023

Comments

Tags

Swagger UI
Swashbuckle
SwashbuckleAspNetCore
Rest API
Postman
Api Testing
ITextSharp
Export to Pdf
AspNet Core
AspNet
C#
View to Pdf in Aspnet
Scheduler
Fibonacci series in Java
Display Fibonacci Series
First C# Program
What is C?
C
C Programming
CodeLobster
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1760
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp Join Us On Facebook
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, India   info@code2night.com

Quick Links
  • Home
  • Blogs
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • XML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • PDF Editor
By Language
  • Angular
  • C
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Built with for developers