-
-
When having only the value from an enum, it is possible to get the enum value.
Try using Enum.IsDefined(typeof(enum), string) and Enum.Pars(typof(enum), string)
-f.
-
-
What to improve your software by adding icons? There is many websites selling them, but there is not many ones with free icon, that you can use legally.
The most popular one is the Fam Fam Fam collection of icons, and I recently found FreeFavicon that is a great collection too.
-f.
-
-
When you want to digitally sign your application using a Strong Name, it is the combination of the SNK, the Assembly name and the public key token that make it unique.
So, you can sign all your assembly using the same SNK, and use a Company wide signature so that you can recognize or validate the signature of your applications.
Also, if you want to keep the SNK private, there is a possibility to delay sign your assemblies.
-f.
Ref:
Sign an Assembly with a Strong Name
Delay sign an assembly
-
-
Did you know that you can simply get the version of the application by going to Application.ProductVersion… ? And you can also get the Assembly version by using reflection, assemblyobject.GetName().Version .
-f.
-
-
(Almost) everybody is using them, but did you even think why?
There is many reasons why using them. The main one, is to control who, when and how caller are accessing the value. You can also validate data before setting it, or expose data, loaded on demand.
More information can be found on MSDN.
-f.
-
-
Multi-threading is the new way to develop, if you want to fully use the computer power. But (there is always a but), if you want to safely update the UI, you must invoke the method, instead of just calling it, when you are not on the Form’s thread.
There is multiple way to do that, and each of them are more or less complex. There is a good tutorial on Code Project, take it a look when it’s time to multithread you app… and remember the “InvokeRequired” attribute of the form/control. Also remember that CheckForIllegalCrossThreadCalls is only working in Debug mode!
-f.
-
-
Often, it is useful to compare object instances between them. The comparison is useful for many things and the most basic one is to sort them.
.NET provide a mechanism to handle it, that is the implementation of IComparable. In .NET 2.0, there is an generic implementation to type the comparison and compare only entities that you can handle. Take a Look a IComparable<>.
Also, you can take a look an article Implementing an Extension to Sort ControlCollection in .NET 3.5 to view an example of what you can to when using this kind of generic interface.
-f.
-
-
Did you know that since .NET 2.0, a generic event handler exists?
In the System root, there is a EventHandler<eventArg>… So, it’s no longer needed to create the typed Handler, just create your EventArgs, and Declare your event!
-f.
-
-
When integrating a Tray Icon to your application, it is a good idea to add a Minimize to Tray option as Outlook.
This can be done using a simple line that detect form resize, and when the WindowState is Minimized, call the Hide() function on the form, and on the doubleclick event of the tray icon, call the Show() function, and change the WindowState to Normal.
-f.
-
-
Documenting code can be very long, and keeping the comments in-sync with the code is even harder.
A solution for that is to use region, instead of comments. This way of documenting has two purpose comment the code, and scope the comment. And also, this force a user to keep the region’s name/comment in-sync, because it is delimiting a part of the code itself.
-f.