Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Oct 2002
Offline Last Active Jan 22 2016 04:46 PM

#5083428 Adding a new copy of an object to a List

Posted by on 05 August 2013 - 09:42 PM

A few other notes on how to do some things in C#. First of all, you don't have to do the string.ToLower in the comparison yourself. You could create a Dictionary which uses a case insensitive string comparer. In the Add function, you don't have to check to see if a key exists before adding it. If your objective is to either add a new item, or replace an existing item, just assign the value via the index. You also don't have to search Dictionaries manually as you are in the create method. As ChaosEngine said, just use TryGetValue. This is what I would do. 


Here is an example showing the changes I would make.


public class ObjectHandler
  private Dictionary<string, Item> objects = new Dictionary<string, Item>(StringComparer.InvariantCultureIgnoreCase);

  public void Add(Item item)
    objects[item.Name] = item;

  public Item Create(string Name)
    Item item;
    if(objects.TryGetValue(Name, out item))
      return item.Clone();
    return null;

I would also strongly consider changing the name from Create to CreateCopy. 


#5045740 C#, Java, Post-PC, Mobile, need pro Advices

Posted by on 22 March 2013 - 03:31 PM

What Bearhugger said is true to an extent. Java has not aged well. Most of the "cool" features are built into other languages which run on the JVM like Clojure and Scala and not added to Java itself. Meanwhile, C# has definitely improved with age. Take a look at the following.





Mono support is typically very good for running on Linux & OSX and with tools like MonoTouch it's possible to write mobile apps in C# which are portable to all major mobile devices. C# is definitely not going anywhere as a language.

#4991661 Seeking resume advice

Posted by on 18 October 2012 - 09:48 PM

That, sir, is purely untrue.
You wouldn't believe the insane amount of people being hired off ties that they may not have foreseen. I understand the need to trim, but seriously, you never know when a cheap-ass job is going to net you an interview. I've seen buger-flippers net an interview based on the fact they had survived that hell for 3 straight years alone. Other applicants with surpassing amounts of years in the industry were not even contacted... attitude counts, and an educated guess can go through looking at what you did before.

That said, yes, you need some trimming...

So you're saying leave random crap in your resume because the person hiring might have a personality quirk?

#4991657 Seeking resume advice

Posted by on 18 October 2012 - 09:30 PM

No one cares where you went to high school, and of course your references are available upon request. It could also use some formatting.

Here is my resume which I am reasonably happy with. I've remove a few companies to keep it at two pages, and I'll have to do some more shuffling to fit in my latest company.


The skills section gets changes based on who I'm sending the resume to. I emphasize the skills that the company is looking for. At this point my resume is more of a formality anyway. My last four jobs have been through networking.

#4967878 Card Shuffle - Opinions

Posted by on 09 August 2012 - 01:23 PM

There is an excellent StackOverflow answer for shuffling an IList<T>.

Randomize a list in C#

Some important takeaways:
  • As already mentioned, you can do inline replacement. No need for a new list.
  • Random may not be random enough. (When random is too consistent...)
  • Extension methods rock!

#4967874 md5+salt

Posted by on 09 August 2012 - 01:09 PM

And this is why you should never sign up for membership on random websites unless you use a throw away password and don't provide any sensitive information. If you have to ask this question, you should NOT be writing a login system for a website. You should definitely use bcrypt as Bactarius suggessted as MD5 and SHA are insufficient for secure hashes.

Our Password Hashing Has No Clothes
Utilizing the GPU, he was able to crack over 24,000 sha hashed and salted passwords in 45 minutes.

#4962027 C# Java Html5 need expert Advices

Posted by on 22 July 2012 - 02:57 PM

That is not true. Windows Forms and the classical Win32/COM stuff is still there, it is now simply excluded from the Express editions. You have to have at least professional.

Edit: Yep, to confirm it I just opened the VM with Win8 & VS 12. All the stuff and project templates are there. Getting professional edition is easy peasy: it is free for academic purposes (MSDN AA/Dreamspark) and start-ups. If you can afford to hire and pay more than 5 developers, you should be able to afford the $500.

There will be an express version.


#4961414 Interfaces vs Abstract Classes as a module boundary.

Posted by on 20 July 2012 - 01:15 PM

They are equivalent except for the fact that C# does not support multiple inheritance. That means while you can implement multiple interfaces, you cannot have more than one base class, abstract or otherwise. If it truly is an abstract base class (no functionality built in at all), I always use interfaces so not to preclude the use of a base class, and question the usefulness of a pure abstract base class.

#4880377 Are 99%ers poking fingers at a failure of capitalism?

Posted by on 03 November 2011 - 10:41 PM

Oh nice, today we get a look at Fortune 500 companies that pay ZERO dollars in taxes:


On a combined $160,000,000,000 in profits for these companies.. our government paid THEM a refund of $10 BILLION, making taxation actually profitable for these companies.

How the hell do you keep billions of dollars from being taxed? Oh.. jeez it gets complicated - http://news.cnet.com...020329-265.html

I don't believe that the problems OWS are complaining about are a problem of capitalism. Our government effectively creates and supports monopolies. Politicians are sitting on the boards of these giant corporations and have a monetary interest in ensuring there are plenty of loopholes for the company to take advantage of all while the would be competition is saddled with one of the highest corporate tax rates in the world. We have a two party system where democrats and republicans simply trade power back and forth as you get pissed off at one side and turn to the other for support. It is a system designed to keep power consolidated in a relatively small group. OWS would probably be more on target if they were occupying DC instead.

The worst part of it is there are jobs to be had, but they are not and are no longer going to be unskilled. We are not just exporting our jobs, we are importing skilled workers from other countries because there are not enough qualified Americans to do the jobs. The US education system is broken and failing at preparing our children to compete in the future market and despite what many claim, it's not simply a matter of being underfunded. The teachers unions have a stranglehold on our education system and are putting the future of this country in jeopardy. There is another great target for the OWS crowd, but they seem more interested in calling attention to the symptoms than the underlying problems.

#4869617 Steve Jobs

Posted by on 05 October 2011 - 07:25 PM

It is with deep regret that I announce this... He revolutionized personal computing and effectively created the laptop industry. Post your thoughts. And rememer this great man.

Apple sucks! GO Microsoft!

Wrong thread?

Seriously though, I'm no Apple fan, but this guy had a huge impact on the technology industry, and the world is likely better for it. Makes you wonder what he could have done if the had the other 20+ years that he should have had.

#4865004 Files can always be recovered no matter what you do...

Posted by on 22 September 2011 - 09:26 PM

When I have to be certain something is erased and not recoverable... I use this tool:

Posted Image

#4863995 The dumbest products you've seen advertised

Posted by on 20 September 2011 - 05:02 PM

Posted Image
ok I dug out the old keyboard (hence the dust) if you accidentally(*) press the power button it will shut off the machine (just like the power supply has been turned off) i.e. it wont save things first

(*)& with it being so close to other keys I done it ~3x before I got a new keyboard, a little switch on the corner or something that youre accidentally not going to touch is a far better idea

If we're just talking about poor design decisions... there are millions of examples of those floating around. I agree with the others that the concept isn't necessarily useless however.

#4863610 The dumbest products you've seen advertised

Posted by on 19 September 2011 - 06:32 PM

Wait, what? Who wouldn't want an oral sex light?

#4859322 Programming Job Postings - They Suck!

Posted by on 08 September 2011 - 08:03 PM

No, it's a good thing. If their job ad sucks then it was likely written by an HR drone, which means the company employs HR drones, which indicates it's not a company I'd like to work for. Sounds like a good way to pick out the crappy jobs to me!

#4859320 Standardised transportation network

Posted by on 08 September 2011 - 07:47 PM

Do you live in Europe? Placing capsules onto a plane automagically is another option since it's unrealistic to run the tubes under the ocean and maintain them.

You're just full of these gems. Spanning oceans with your magic pipes is far, far easier than connecting every city in a nation. We already have plenty of cables across the ocean and this has been done for over a hundred years.