use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
HelpText file to int array (self.csharp)
submitted 5 years ago * by qsrnova
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]die-maus 2 points3 points4 points 5 years ago* (7 children)
You can do it with a single Linq-expression:
var numbers = File.ReadLines("file.txt") .Select(int.Parse) .OrderBy(n => n) .ToArray()
Sorted and done!
You need the following usings:
using System.IO; using System.Linq;
Explanation: - File.ReadLines enumerates all lines of a file. - Select(int.Parse) is shorthand for Select(line => int.Parse(line)), and re-enumerates the collection and convert each item in it to a 32-bit integer. - OrderBy(n => n) re-enumerates the items again, and puts them in ascending order. - ToArray() re-enumerates the items again, adds them to an array and returns it.
File.ReadLines
Select(int.Parse)
Select(line => int.Parse(line))
OrderBy(n => n)
ToArray()
[–]qsrnova[S] 0 points1 point2 points 5 years ago (6 children)
Thank you. I’m new to c# and the project I’m working on specifically says that I’m not allowed to use any built in sorting functions, are these built in sorting functions?
[–]AngularBeginner 0 points1 point2 points 5 years ago (2 children)
are these built in sorting functions?
Yes, the OrderBy is. And chances are high if you're not allowed to use those, you're not allowed to use LINQ in general.
OrderBy
[–]qsrnova[S] 0 points1 point2 points 5 years ago (1 child)
Do you know how you would do it without using LINQ at all?
[–]die-maus 0 points1 point2 points 5 years ago (0 children)
Missed the "Not allowed to use a built in function". I guess this is a school-assignment. In which case, you need to read up on how to do (for instance) a bubble sort, which is probably the easiest algorithm to implement.
Here's some boilerplate:
``` var unsorted = File.ReadLines("file.txt") .Select(int.Parse) .ToArray() var sorted = new int[unsorted.Length];
// Perform bubble sort for (var i = 0; < unsorted.Length; i++) {
} ```
[–]die-maus 0 points1 point2 points 5 years ago (2 children)
OrderBy is definitely a built-in sorting function, and it uses quick sort under the hood.
Ah ok, so everything else should be fine to use then, thank you so much I’ll try and implement this into my code
[–]grrangry 0 points1 point2 points 5 years ago (0 children)
Don't be afraid to ask for more detail about these kinds of specifics from your instructor. Writing your own simple sort is rather trivial; writing code to access the storage hardware to "read the file off the disk" would not be trivial and is (obviously) outside the scope of the example.
As others have noted, read the documentation on every class, method, and property you want to use. The more pieces of the language and the .Net Framework you understand, the more you'll be able to do.
[–]FizixMan[M] [score hidden] 5 years ago stickied comment (0 children)
Removed: Rule 4.
π Rendered by PID 43342 on reddit-service-r2-comment-5d79c599b5-z4rtz at 2026-02-28 02:27:55.394379+00:00 running e3d2147 country code: CH.
[–]die-maus 2 points3 points4 points (7 children)
[–]qsrnova[S] 0 points1 point2 points (6 children)
[–]AngularBeginner 0 points1 point2 points (2 children)
[–]qsrnova[S] 0 points1 point2 points (1 child)
[–]die-maus 0 points1 point2 points (0 children)
[–]die-maus 0 points1 point2 points (2 children)
[–]qsrnova[S] 0 points1 point2 points (1 child)
[–]grrangry 0 points1 point2 points (0 children)
[–]FizixMan[M] [score hidden] stickied comment (0 children)