Desktop Programming
|
Windows Forms |
28 Jun 2011
Updated: 28 Jun 2011
Rating: 4.17/5
Votes: 3
Popularity: 1.99
Licence: CPOL
Views: 15,091
Bookmarked: 1
Downloaded: 0
Couldn't the class RegEdit be replaced by one simple method?private void SetKey(bool enableTaskManager) { using ( var mKey = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System")) {...
|
DevOps
|
Unit Testing |
3 Jan 2016
Updated: 3 Jan 2016
Rating: 5.00/5
Votes: 1
Popularity: 0.00
Licence: CPOL
Views: 22,515
Bookmarked: 1
Downloaded: 0
How to replace the System.Timer with a mock object when testing
|
General Programming
|
Algorithms |
7 Feb 2023
Updated: 7 Feb 2023
Rating: 4.00/5
Votes: 1
Popularity: 0.00
Licence: CPOL
Views: 6,161
Bookmarked: 4
Downloaded: 32
A .NET7 version of a Rotated Binary Search method
|
Regular Expressions |
18 Oct 2011
Updated: 18 Oct 2011
Rating: 5.00/5
Votes: 7
Popularity: 4.23
Licence: CPOL
Views: 9,321
Bookmarked: 2
Downloaded: 0
The Regex method uses comma, full stop, hyphen, and apostrophe as word separators. The problem with this is that these characters are not universally used as separators. The hyphen is used to join two words. Could I suggest the following?string input = "Mr O'Brien-Smith arrived at 8.30 and...
|
String |
30 Jun 2011
Updated: 30 Jun 2011
Rating: 0.00/5
Votes: 0
Popularity: 0.00
Licence: CPOL
Views: 7,652
Bookmarked: 0
Downloaded: 0
You can use the Aggregate method with a StringBuilder. I've modified Eric's alternative in order to save a bit of code. Only one return statement is needed as an empty StringBuilder returns an empty string.public static string Join(this IEnumerable parts, string separator) { ...
|
|
3 Feb 2013
Updated: 3 Feb 2013
Rating: 0.00/5
Votes: 0
Popularity: 0.00
Licence: CPOL
Views: 14,643
Bookmarked: 5
Downloaded: 0
This is an alternative for "Dictionary.BestMatch"
|
Operating Systems
|
Windows |
19 Nov 2011
Updated: 19 Nov 2011
Rating: 5.00/5
Votes: 2
Popularity: 1.51
Licence: CPOL
Views: 7,821
Bookmarked: 3
Downloaded: 0
I prefer alternative 3 but this option may save time if multiple files are to be deleted.Disk Cleanup will remove all files stored in a folder named Windows.old in the drive's root if the option Remove Previous Versions of Windows is selected.Create a directory named Windows.old in the...
|
Programming Languages
|
C# |
23 Feb 2016
Updated: 24 Feb 2016
Rating: 4.50/5
Votes: 4
Popularity: 2.71
Licence: CPOL
Views: 11,973
Bookmarked: 2
Downloaded: 0
This is an alternative for "Get a list of Dates for the Nth Desired Day of Week in a Month for a range of dates"
|
|
11 Jan 2012
Updated: 11 Jan 2012
Rating: 0.00/5
Votes: 0
Popularity: 0.00
Licence: CPOL
Views: 8,033
Bookmarked: 0
Downloaded: 0
How about using the extension method: return s.Count(c => (c == '\n'));
|
|
22 Oct 2011
Updated: 22 Oct 2011
Rating: 4.38/5
Votes: 5
Popularity: 3.06
Licence: CPOL
Views: 14,521
Bookmarked: 0
Downloaded: 0
Isn't it possible to remove the from and select statements by using a lambda expression?var bestStudents=students.Where(s=>s.Grade>9);
|
|
19 Jun 2017
Updated: 19 Jun 2017
Rating: 4.60/5
Votes: 4
Popularity: 2.77
Licence: CPOL
Views: 8,641
Bookmarked: 2
Downloaded: 0
An introduction to the Reservoir Sampling of Data Streams.
|
|
6 May 2020
Updated: 6 May 2020
Rating: 5.00/5
Votes: 3
Popularity: 2.39
Licence: CPOL
Views: 5,734
Bookmarked: 1
Downloaded: 55
An alternative solution to the Spiral Print problem
|
|
30 Mar 2013
Updated: 31 Mar 2013
Rating: 4.94/5
Votes: 3
Popularity: 2.36
Licence: CPOL
Views: 27,444
Bookmarked: 10
Downloaded: 0
An easy way to read CSV files.
|
|
13 Feb 2011
Updated: 13 Feb 2011
Rating: 5.00/5
Votes: 1
Popularity: 0.00
Licence: CPOL
Views: 8,331
Bookmarked: 1
Downloaded: 0
You can use Linq to do the same thing double[] mydouble = str.Split('#').Select(x => double.Parse(x)).ToArray();
|
|
12 Sep 2011
Updated: 12 Sep 2011
Rating: 0.00/5
Votes: 0
Popularity: 0.00
Licence: CPOL
Views: 9,210
Bookmarked: 0
Downloaded: 0
The following method starts by selecting the number 2 and eliminates each multiple of 2 up to N. Then the next valid number is selected and each multiple of it is eliminated. The process is repeated until all valid numbers have been tested. So the first three multiples to be eliminated are...
|
|
4 Oct 2011
Updated: 4 Oct 2011
Rating: 4.71/5
Votes: 4
Popularity: 2.84
Licence: CPOL
Views: 12,121
Bookmarked: 1
Downloaded: 0
Recursion is a neat way of calculating a number's factorial but there is a danger of the stack overflowing when the number is large. The following is a simplified version of the original. It obviates the need for the if else statements within the where loop.int Factorial(int input){ int...
|
|
15 Jun 2011
Updated: 15 Jun 2011
Rating: 5.00/5
Votes: 2
Popularity: 1.51
Licence: CPOL
Views: 9,230
Bookmarked: 0
Downloaded: 0
As it stands, the TryParse method will fail if the string contains commas. E.g., 10,000. To get around this, you can use:bool isnumber=int.TryParse(text,System.Globalization.NumberStyles.Integer | System.Globalization.NumberStyles.AllowThousands, ...
|
|
3 Nov 2011
Updated: 3 Nov 2011
Rating: 5.00/5
Votes: 3
Popularity: 2.39
Licence: CPOL
Views: 12,021
Bookmarked: 1
Downloaded: 0
Can't this be done with a simple for loop followed by a single if statement?for(int i=0;i<characters.Length-1;i+=2){ output.Append(characters[i+1]); output.Append(characters[i]);}if (characters.Length % 2 == 1) output.Append(characters[characters.Length - 1]);
|
|
16 Jun 2021
Updated: 16 Jun 2021
Rating: 4.00/5
Votes: 2
Popularity: 1.20
Licence: CPOL
Views: 12,424
Bookmarked: 3
Downloaded: 0
How to add a Spinner to a long-running library method
|
C# 3.5 |
15 Oct 2011
Updated: 15 Oct 2011
Rating: 4.00/5
Votes: 5
Popularity: 2.80
Licence: CPOL
Views: 11,080
Bookmarked: 1
Downloaded: 0
The tcpEndPoints array has duplicates and members outside the required range. It may be better to restrict the array members to the required range, sort them, and remove the duplicates. The first free port can then be found by finding the first non-sequential value.using...
|
XML |
24 Aug 2011
Updated: 24 Aug 2011
Rating: 0.00/5
Votes: 0
Popularity: 0.00
Licence: CPOL
Views: 13,832
Bookmarked: 0
Downloaded: 0
Can't you do the same thing without the need for a select statement?XElement xElement = XElement.Load(path);xElement.Elements ("Node").Remove();xElement.Save(path);
|
Web Development
|
ASP.NET |
11 Nov 2011
Updated: 11 Nov 2011
Rating: 0.00/5
Votes: 0
Popularity: 0.00
Licence: CPOL
Views: 7,761
Bookmarked: 0
Downloaded: 0
Is it easier to start from the next targeted day? Subtract that date from the end date. If the result is negative, return 0 otherwise return the quotient of the difference in days between the two dates divided by 7 plus 1.public static int findWeekCount(DateTime startDate, DateTime toDate,...
|