How do I remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?

Start debugging, as soon as you’ve arrived at a breakpoint or used Debug > Break All, use Debug > Windows > Modules. You’ll see a list of all the assemblies that are loaded into the process. Locate the one you want to get debug info for. Right-click it and select Symbol Load Information. You’ll get … Read more

How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?

You can use a library called ExcelLibrary. It’s a free, open source library posted on Google Code: ExcelLibrary This looks to be a port of the PHP ExcelWriter that you mentioned above. It will not write to the new .xlsx format yet, but they are working on adding that functionality in. It’s very simple, small … Read more

Should ‘using’ directives be inside or outside the namespace?

There is actually a (subtle) difference between the two. Imagine you have the following code in File1.cs: // File1.cs using System; namespace Outer.Inner { class Foo { static void Bar() { double d = Math.PI; } } } Now imagine that someone adds another file (File2.cs) to the project that looks like this: // File2.cs … Read more

How do I get a consistent byte representation of strings in C# without manually specifying an encoding?

Contrary to the answers here, you DON’T need to worry about encoding if the bytes don’t need to be interpreted! Like you mentioned, your goal is, simply, to “get what bytes the string has been stored in”. (And, of course, to be able to re-construct the string from the bytes.) For those goals, I honestly … Read more

Difference between decimal, float and double in .NET?

float and double are floating binary point types (float is 32-bit; double is 64-bit). In other words, they represent a number like this: 10001.10010110011 The binary number and the location of the binary point are both encoded within the value. decimal is a floating decimal point type. In other words, they represent a number like … Read more

Deep cloning objects

Whereas one approach is to implement the ICloneable interface (described here, so I won’t regurgitate), here’s a nice deep clone object copier I found on The Code Project a while ago and incorporated it into our code. As mentioned elsewhere, it requires your objects to be serializable. using System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; … Read more

What are the correct version numbers for C#?

C# language version history: These are the versions of C# known about at the time of this writing: C# 1.0 released with .NET 1.0 and VS2002 (January 2002) C# 1.2 (bizarrely enough); released with .NET 1.1 and VS2003 (April 2003). First version to call Dispose on IEnumerators which implemented IDisposable. A few other small features. … Read more