All Questions

1881
votes
33answers
818917 views

What is a NullReferenceException, and how do I fix it?

I have some code and when it executes, it throws a NullReferenceException, saying: Object reference not set to an instance of an object. What does this mean, and what can I do to fix this error?...
1050
votes
43answers
492936 views

How do I update the GUI from another thread in C#?

What is the simplest way to update a Label from another thread? I have a Form on thread1, and from that I'm starting another thread (thread2). While thread2 is processing some files I would like to u...
117
votes
3answers
79766 views

What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?

I have some code and when it executes, it throws a IndexOutOfRangeException, saying, Index was outside the bounds of the array. What does this mean, and what can I do about it? Depending on cl...
1116
votes
16answers
142244 views

What is the best algorithm for an overridden System.Object.GetHashCode?

In .NET System.Object.GetHashCode method is used in a lot of places, throughout the .NET base class libraries. Especially when finding items in a collection fast or to determine equality. Is there a ...
1663
votes
37answers
641364 views

Deep cloning objects

I want to do something like: MyObject myObj = GetMyObj(); // Create and fill a new object MyObject newObj = myObj.Clone(); And then make changes to the new object that are not reflected in the orig...
1428
votes
40answers
856204 views

Create Excel (.XLS and .XLSX) file from C#

How can I create an Excel Spreadsheet with C# without requiring Excel to be installed on the machine that's running the code?
700
votes
21answers
454645 views

Deserialize JSON into C# dynamic object?

Is there a way to deserialize JSON content into a C# 4 dynamic type? It would be nice to skip creating a bunch of classes in order to use the DataContractJsonSerializer.
704
votes
21answers
435237 views

Sending email in .NET through Gmail

Instead of relying on my host to send email, I was thinking of sending the email messages using my Gmail account. The emails are personalized emails to the bands I play on my show. Is it possible to d...
554
votes
23answers
554355 views

Encrypt and decrypt a string

Can someone give me the code to encrypt and decrypt a string in C#?
66
votes
15answers
361066 views

What is the best way to parse html in C#?

I'm looking for a library/method to parse an html file with more html specific features than generic xml parsing libraries.

Previous Next