Database Development
|
SQL Server |
30 Nov 2010
Updated: 30 Nov 2010
Rating: 4.92/5
Votes: 6
Popularity: 3.83
Licence: CPOL
Views: 8,800
Bookmarked: 2
Downloaded: 0
You might want to do some further testing... It seems if you perform the following, the values are actually the same:SET NOCOUNT ONDECLARE @TMP TABLE( EmpName VARCHAR(50), Age INT)PRINT CONVERT(VARCHAR, GETDATE(), 121)INSERT INTO @TMP(EmpName, Age)SELECT 'Ravi Kiran',...
|
Desktop Programming
|
Windows Forms |
20 Feb 2011
Updated: 20 Feb 2011
Rating: 4.92/5
Votes: 4
Popularity: 2.96
Licence: CPOL
Views: 15,052
Bookmarked: 2
Downloaded: 0
Just a few minor improvements to readability and such...The catch/throw isn't needed here, since you are just throwing it without doing anything in the catch block. A try/finally could have been used on its own.The try/finally isn't necessary because a using statement can achieve the same...
|
WPF |
18 Jun 2010
Updated: 18 Jun 2010
Rating: 4.75/5
Votes: 6
Popularity: 3.70
Licence: CPOL
Views: 15,700
Bookmarked: 1
Downloaded: 0
Or even...if (frm.ShowDialog() == true){ // do something here}
|
DevOps
|
Testing |
22 Jun 2011
Updated: 22 Jun 2011
Rating: 5.00/5
Votes: 2
Popularity: 1.51
Licence: CPOL
Views: 18,444
Bookmarked: 1
Downloaded: 0
A simple trick to remove the delay of Thread.Sleep for unit testing.
|
|
11 Aug 2011
Updated: 12 Aug 2011
Rating: 4.89/5
Votes: 2
Popularity: 1.47
Licence: CPOL
Views: 14,760
Bookmarked: 1
Downloaded: 0
Using an attached behavior to expose the value of a DataContext for Automation
|
Expression blend
|
|
27 May 2010
Updated: 27 May 2010
Rating: 5.00/5
Votes: 5
Popularity: 3.49
Licence: CPOL
Views: 16,520
Bookmarked: 2
Downloaded: 0
A tip to overcome limitations in Blend 3 and Blend 4 RC when dealing with attached dependency properties.
|
General Programming
|
Performance |
26 Oct 2010
Updated: 27 Oct 2010
Rating: 5.00/5
Votes: 3
Popularity: 2.39
Licence: CPOL
Views: 12,970
Bookmarked: 2
Downloaded: 0
Technically, the best approach here for speed and flexibility is to do the following:public class TestClass{ private const string EMP_ID = "EmpId"; public void MyTestMethod() { //GetData fetches data from the database using a SQL query DataTable dt =...
|
Sorting |
8 Mar 2011
Updated: 16 Mar 2011
Rating: 4.96/5
Votes: 12
Popularity: 5.17
Licence: CPOL
Views: 77,034
Bookmarked: 9
Downloaded: 0
How to sort a two-dimensional array in C#
|
Programming Languages
|
C# |
25 Jan 2012
Updated: 26 Jan 2012
Rating: 4.67/5
Votes: 4
Popularity: 2.81
Licence: CPOL
Views: 18,101
Bookmarked: 3
Downloaded: 0
Using expressions, you can achieve a faster result with less code.public static T New(){ Type t = typeof(T); Func method = Expression.Lambda>(Expression.Block(t, new Expression[] { Expression.New(t) })).Compile(); return method();}Furthermore, this can...
|
|
11 Oct 2011
Updated: 12 Oct 2011
Rating: 3.48/5
Votes: 7
Popularity: 2.94
Licence: CPOL
Views: 14,591
Bookmarked: 1
Downloaded: 0
I was actually going to suggest a simpler version of cechode's version, but along the same lines.public static IEnumerable Randomize(this IEnumerable source){ Random r = new Random(); return source.Select(x => new { Key = r.Next(), Value = x }) .OrderBy(x => x.Key) ...
|
|
11 May 2011
Updated: 11 May 2011
Rating: 5.00/5
Votes: 3
Popularity: 2.39
Licence: CPOL
Views: 11,750
Bookmarked: 1
Downloaded: 0
Three improvement ideas:-Add check to ensure the enum is a [Flags] enum.-Make the method generic and static with the enum type generic. I don't know how common it would be to have the type already on hand. It makes it simpler to use.-Iterate over all of the values and bit-wise or them...
|
|
13 Dec 2012
Updated: 17 Dec 2012
Rating: 4.00/5
Votes: 5
Popularity: 2.80
Licence: CPOL
Views: 31,877
Bookmarked: 9
Downloaded: 0
A method for calculating a Fibonacci number without using loops or recursion.
|
|
9 Apr 2011
Updated: 9 Apr 2011
Rating: 5.00/5
Votes: 5
Popularity: 3.49
Licence: CPOL
Views: 11,470
Bookmarked: 3
Downloaded: 0
I would actually go the route getting those developers to follow good practice. As a whole, the field would be better off if developers like that were mentored rather than something like this.So, I would recommend using either of the techniques you put forth originally (using the Data...
|
|
1 Dec 2010
Updated: 1 Dec 2010
Rating: 5.00/5
Votes: 7
Popularity: 4.23
Licence: CPOL
Views: 9,211
Bookmarked: 2
Downloaded: 0
I'd recommend a minor tweak to your code to remove the 'magic' string of the mimeType from the code, using the following:static void Main(string[] args){ Bitmap bitMap = new Bitmap(@"test.bmp"); var codecInfo = GetEncoderInfo(ImageFormat.Gif); var paramsEncoder = new...
|
|
14 Jan 2011
Updated: 14 Jan 2011
Rating: 5.00/5
Votes: 5
Popularity: 3.49
Licence: CPOL
Views: 9,680
Bookmarked: 1
Downloaded: 0
Not really that big of a change, but I'd go with an XPath solution. It locates all of the "magic strings" into one spot.var nodes = from element in XElement.Load("Books.xml").XPathSelectElements("/Books/Book/Subject") select new { Value =...
|
|
31 Mar 2011
Updated: 2 Apr 2011
Rating: 5.00/5
Votes: 7
Popularity: 4.23
Licence: CPOL
Views: 15,390
Bookmarked: 1
Downloaded: 0
How to get that last little nagging line to be covered...
|
|
4 Oct 2011
Updated: 18 Oct 2011
Rating: 5.00/5
Votes: 8
Popularity: 4.52
Licence: CPOL
Views: 20,326
Bookmarked: 1
Downloaded: 0
Or you could just go the other direction and cache the known results ahead of time. You're only looking at 13 numbers in all, so it is not a big memory hog to just store those known values inside of the method and be done with it.static uint Factorial(uint x){ if (x > 12) throw...
|
|
5 Dec 2011
Updated: 5 Dec 2011
Rating: 5.00/5
Votes: 5
Popularity: 3.49
Licence: CPOL
Views: 7,890
Bookmarked: 2
Downloaded: 0
Or you could just do the following without using System.Management:foreach (var driveInfo in DriveInfo.GetDrives().Where(x => x.DriveType == DriveType.CDRom)){ if (driveInfo.IsReady) Console.WriteLine("CD is ready in drive: " + driveInfo.Name); else Console.WriteLine("CD...
|
|
5 Jan 2012
Updated: 12 Jan 2012
Rating: 4.73/5
Votes: 8
Popularity: 4.27
Licence: CPOL
Views: 27,090
Bookmarked: 2
Downloaded: 0
After describing it so much, I felt the need to go ahead and implement it. So here goes...using System;using System.Collections.Generic;using System.ComponentModel;using System.Linq.Expressions;using System.Reflection;namespace DefaultValue{ /// /// The...
|
C# 4.0 |
25 Jul 2012
Updated: 25 Jul 2012
Rating: 5.00/5
Votes: 1
Popularity: 0.00
Licence: CPOL
Views: 10,071
Bookmarked: 2
Downloaded: 0
This is an alternative for "Ad-Hoc Expression Evaluation"
|
|
31 Aug 2012
Updated: 31 Aug 2012
Rating: 4.00/5
Votes: 1
Popularity: 0.00
Licence: CPOL
Views: 11,090
Bookmarked: 5
Downloaded: 0
A function to generate an endless collection of scrolling text for your use/amusement.
|
C++ |
10 Feb 2011
Updated: 10 Feb 2011
Rating: 4.95/5
Votes: 11
Popularity: 4.95
Licence: CPOL
Views: 12,880
Bookmarked: 3
Downloaded: 0
Always review all changes before submitting them. Especially, if using a global find and replace.
|
SQL |
3 Jul 2010
Updated: 3 Jul 2010
Rating: 5.00/5
Votes: 3
Popularity: 2.39
Licence: CPOL
Views: 16,340
Bookmarked: 4
Downloaded: 0
Using the pattern that Microsoft SQL Server Management Studio creates, it would be something along the lines of:IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[com_CountString]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))DROP FUNCTION...
|
Visual Basic |
13 Feb 2011
Updated: 14 Feb 2011
Rating: 4.75/5
Votes: 8
Popularity: 4.29
Licence: CPOL
Views: 15,020
Bookmarked: 3
Downloaded: 0
The following samples should take advantage of using statements and furthermore built in features of the ADO.NET framework. Furthermore, if you open a connection, make sure you open it at the latest time possible and close it as soon as possible.Edit: While I was originally not trying to...
|
Web Development
|
HTML |
27 Oct 2011
Updated: 28 Oct 2011
Rating: 4.68/5
Votes: 6
Popularity: 3.65
Licence: CPOL
Views: 15,890
Bookmarked: 2
Downloaded: 0
I would have actually opted to remove the start index being passed in. Then, you can spruce up the calls with extension methods (albeit not necessary).Usage:removeList.AddRange(html.ToString().GetBetween("");Code:public static class StringUtilities{ ///...
|