All Questions

1811
votes
30answers
773669 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?...
1020
votes
43answers
481921 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...
110
votes
2answers
73605 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...
1098
votes
16answers
137252 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 ...
1630
votes
37answers
629042 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...
1388
votes
39answers
839472 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?
690
votes
21answers
425757 views

Sending email in .NET through Gmail

Instead of relying on my host to send email, I was thinking of sending the messages though my Gmail account. The emails are personalized emails to the bands I play on my show. Is it possible to do?
682
votes
21answers
435013 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.
538
votes
23answers
541602 views

Encrypt and decrypt a string

Can someone give me the code to encrypt and decrypt a string in C#?
66
votes
15answers
355656 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