Click here to Skip to main content
15,887,337 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Virus Or Worm? Pin
WebMaster3-Nov-12 10:04
WebMaster3-Nov-12 10:04 
GeneralRe: Virus Or Worm? Pin
Grant Drury-Green4-Nov-12 14:00
Grant Drury-Green4-Nov-12 14:00 
JokeRe: Virus Or Worm? PinPopular
Chris Meech5-Nov-12 7:22
Chris Meech5-Nov-12 7:22 
JokeRe: Virus Or Worm? PinPopular
WebMaster5-Nov-12 8:13
WebMaster5-Nov-12 8:13 
GeneralRe: Virus Or Worm? Pin
Super Lloyd5-Nov-12 17:41
Super Lloyd5-Nov-12 17:41 
QuestionRe: Virus Or Worm? Pin
WebMaster5-Nov-12 19:02
WebMaster5-Nov-12 19:02 
AnswerRe: Virus Or Worm? Pin
Brisingr Aerowing8-Nov-12 9:30
professionalBrisingr Aerowing8-Nov-12 9:30 
GeneralTrick for young players. Pin
_Maxxx_31-Oct-12 15:39
professional_Maxxx_31-Oct-12 15:39 
Look at the prog below - a collection has one(object)bool in it. And I want to find out if one of them exists in the collection.

Using collection.Contains() would seem like a good idea.

But isn't!


C#
class Program
	{
		static void Main(string[] args)
		{
			object arg1 = true;
			object arg2 = true;

			List<object> collection = new List<object>() { arg1 };

			bool first = (collection.Contains(arg1));
			bool second = (collection.Contains(arg2));
			Console.WriteLine(string.Format("{0} {1}", first, second));

			first = false;
			second = false;

			for (int i = 0; i < collection.Count; i++)
			{
				if (collection[i] == arg1)
				{
					first = true;
				}
				if (collection[i] == arg2)
				{
					second = true;
				}
			}

			Console.WriteLine(string.Format("{0} {1}", first, second));

				Console.ReadKey();
		}
	}

MVVM# - See how I did MVVM my way
___________________________________________
Man, you're a god. - walterhevedeich 26/05/2011

.\\axxx
(That's an 'M')

GeneralRe: Trick for young players. Pin
Guirec31-Oct-12 16:06
professionalGuirec31-Oct-12 16:06 
GeneralRe: Trick for young players. Pin
_Maxxx_31-Oct-12 16:57
professional_Maxxx_31-Oct-12 16:57 
GeneralRe: Trick for young players. Pin
Guirec31-Oct-12 16:59
professionalGuirec31-Oct-12 16:59 
GeneralRe: Trick for young players. Pin
_Maxxx_31-Oct-12 17:12
professional_Maxxx_31-Oct-12 17:12 
GeneralRe: Trick for young players. Pin
Guirec31-Oct-12 17:21
professionalGuirec31-Oct-12 17:21 
GeneralRe: Trick for young players. Pin
_Maxxx_31-Oct-12 18:23
professional_Maxxx_31-Oct-12 18:23 
GeneralRe: Trick for young players. Pin
Guirec31-Oct-12 18:25
professionalGuirec31-Oct-12 18:25 
GeneralRe: Trick for young players. Pin
Jörgen Andersson1-Nov-12 0:09
professionalJörgen Andersson1-Nov-12 0:09 
GeneralRe: Trick for young players. Pin
BobJanova1-Nov-12 3:28
BobJanova1-Nov-12 3:28 
GeneralRe: Trick for young players. Pin
Jörgen Andersson1-Nov-12 5:07
professionalJörgen Andersson1-Nov-12 5:07 
GeneralRe: Trick for young players. Pin
Florin Jurcovici2-Nov-12 1:41
Florin Jurcovici2-Nov-12 1:41 
GeneralRe: Trick for young players. Pin
BobJanova1-Nov-12 3:26
BobJanova1-Nov-12 3:26 
GeneralRe: Trick for young players. Pin
J4amieC31-Oct-12 22:24
J4amieC31-Oct-12 22:24 
GeneralRe: Trick for young players. Pin
Jörgen Andersson1-Nov-12 0:12
professionalJörgen Andersson1-Nov-12 0:12 
GeneralRe: Trick for young players. Pin
_Maxxx_1-Nov-12 1:35
professional_Maxxx_1-Nov-12 1:35 
GeneralRe: Trick for young players. Pin
J4amieC1-Nov-12 2:05
J4amieC1-Nov-12 2:05 
GeneralRe: Trick for young players. Pin
_Maxxx_1-Nov-12 2:12
professional_Maxxx_1-Nov-12 2:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.