Contents tagged with c#
-
Using MiniProfiler with a hybrid asp.net Web Forms / MVC application - Part 1
If you've got an application, like we have, that uses asp.net Web Forms for the UI components and MVC (5) for the endpoints that are used by JavaScript to retrieve/save data, it's still posible to …
-
Getting a type value from the Request object
A little bit of boiler-plate code I've used in the past for retrieving a value from the asp.net Request object (when working with webform back in the day!) is:
/// <summary>/// Retrieve a value from …
-
A custom model binder for XML content
Most of the time the default model binder in MVC suffices and maps everything into your model cleanly. One thing that you can't do automatically is read XML into an XDocument. You could solve this …
-
Windows Forms marquee style progress bar that doesn't, well, marquee..
If you've got a progress bar where the Style is set to "ProgressBarStyle.Marquee" and the progress bar sits there blank, not scrolling and looking rather sorry for itself, one reason for this is that …
-
DataTable Key/Value columns to Dictionary
There are undoubtedly more elegant ways to do this using LINQ, but to quickly and easily take the key (int) and value (string) columns from a DataTable and turn them into a Dictionary<int, string>, …
-
MySql ServerName.Log file size
A quick and dirty hack (written in C#) to solve the issue of MySql query log files getting huuuge:
System.ServiceProcess.ServiceController sc = new ServiceController("mysql", "servername");sc.Stop(); …
-
MySql - Running a complex script using the .net Connector
[The solution was discovered via this entry in the mysql.com forums]
If your MySql script contains code like
"/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"
You'll need to add …
-
A string of character 'x' the same length as string 'y'
... is quite simple in .net, as I found out! string title = "My line of text that I'm writing to the console underlined with equals signs"; Console.WriteLine(title); …
-
Sorting the results of DirectoryInfo.GetFiles
Say you wanted toget a list of all the SLN (Visual Studio Solution) files in a given directory and all child directories, sorted alphabetically, you could use something similar to this:
public …
-
A number that equals twice the sum of its decimal digits
Riffing on "dix-huit ans aujoud'hui = 18 pounds!" from Frankarr, an australian blogger.
In the entry he mentions that "One fact about 18 which I really love is that 18, aside from 0, is the only …