Drawing text in .NET
I'm doing some tests about drawing text in .Net and I had the following results. ![Drawing text example](https://i.stack.imgur.com/bRcps.png) - `FlatStyle``System`- [Graphics.DrawString()](http://ms...
- Modified
- 1 Sep at 10:29
Get all pairs in a list using LINQ
How do I get all possible pairs of items in a list (order not relevant)? E.g. if I have ``` var list = { 1, 2, 3, 4 }; ``` I would like to get these tuples: ``` var pairs = { new Tuple(1, 2), ...
- Modified
- 3 May at 18:57
C#: SQL Query Builder Class
Where can I find a good SQL Query builder class. I just need a simple class to build a SQL string and that is it. I will need it for C# and MySql. I really don't need anything like Linq or NHibernate....
Is `Request.IsLocal` secure?
Is the property `Request.IsLocal` spoofable, or 100% trustworthy? I want to be certain a request is coming from my box only.
High resolution timer
I want to have a timer with about 5millisecond resolution. but the current Timer in .Net has a resolution of about 50ms. I could not find any working solution that creates a high resolution timer, al...
- Modified
- 7 Feb at 10:23
Algorithm to calculate nearest location based on longitude & latitude
I am currently trying to develop an algorithm to calculate which known locations are closest to current known location. I have a list of say 100 known locations (meaning I have both long- and latitud...
- Modified
- 4 Jan at 21:34
Error: An expression tree may not contain a dynamic operation
I use Asp.Net 4 and C#, I use EF 4. I have this query, I receive an error: ``` An expression tree may not contain a dynamic operation ``` --- ``` dynamic o = e.Item.DataItem; var imagesContent...
- Modified
- 19 Aug at 07:56
Unit Test Description question
There is a description entry for Unit Tests in Visual Studio. Is it possible to modify a test description after creation?
- Modified
- 18 Aug at 19:41
Current date and time - Default in MVC razor
When the MVC view page with this textbox, loads , I would like to display current date and time by default. How can I do this? in razor. ``` @Html.EditorFor(model => model.ReturnDate) ```
- Modified
- 18 Aug at 18:18
Union multiple number of lists in C#
I am looking for a elegant solution for the following situation: I have a class that contains a List like ``` class MyClass{ ... public List<SomeOtherClass> SomeOtherClassList {get; set;} ... } ``...
- Modified
- 4 Aug at 21:13
WPF: how do i handle a click on a ListBox item?
In my WPF app I'm handling a ListBox SelectionChanged event and it runs fine. Now I need to handle a click event (even for the already selected item); I've tried MouseDown but it does not work. How c...
- Modified
- 11 Jan at 07:7
B-Trees / B+Trees and duplicate keys
I'm investigating the possibility of putting together a custom storage scheme for my application. It's worth the effort of potentially reinventing the wheel, I think, because both performance and sto...
- Modified
- 19 Aug at 20:32
#If DEBUG is ignored (VB.net or C#)
I have several of these in my code which have been working fine so far: ``` #If DEBUG Then ... some code here #End If ``` Now, i am noticing that, lately, the code inside the " #If DE...
Sending data to USB printer in C#?
I have script code for zebra TLP2844 printer in a text file. I need to print that script file to a printer connected via USB. I executed that script using parallel port by using DOS command: ``` /c ...
- Modified
- 7 Aug at 09:10
C# : change listbox items color
i am working on program on windows forms I have a listbox and I am validating data I want the correct data be added to the listbox with color green while the invalid data added with red color and I al...
Using TypeBuilder to create a pass-through constructor for the base class
Say I have a `SpaceShip` class, like so: ``` public class SpaceShip { public SpaceShip() { } public SpaceShip(IRocketFuelSource fuelSource) { } } ``` I want to use [TypeBuilder](http://ms...
- Modified
- 19 Oct at 03:35
Boolean Property Getter and Setter Locking
Is there any reason why you would create locks around the getter and setter of a boolean property like this? ``` private _lockObject = new object(); private bool _myFlag; public bool MyFlag { ...
- Modified
- 29 Jul at 13:33
Do C# try-finally CERs break in iterators?
Apparently, Constrained Execution Region guarantees do not apply to iterators (probably because of how they are implemented and all), but is this a bug or by design? [See the example below.] i.e. Wha...
- Modified
- 23 May at 12:19
How to use System.Lazy with Setter to Lazy Initialization of List in POCO Entities?
I want to use System.Lazy to Lazy Initialization of my List in my Entites: ``` public class Questionary { private Lazy<List<Question>> _questions = new Lazy<List<Question>>(() => new List<Questio...
- Modified
- 27 Jul at 13:53
When is a .NET namespace implemented by a .NET Framework component?
(Yet another question from my "Clearly I'm the only idiot out here" series.) When I need to use a class from the .NET Framework, I dutifully look up the documentation to determine the corresponding n...
- Modified
- 27 Jul at 17:30
How can I limit the length of a string to 150 characters?
I tried the following: ``` var a = description.Substring(0, 150); ``` However this gives a problem if the length of description is less than 150 chars. So is there another way I can limit the lengt...
- Modified
- 26 Jul at 16:16
MyClass equivalent in C#
In looking at [this question](https://stackoverflow.com/questions/6830825/shared-class-field-in-visual-basic), commenter @Jon Egerton mentioned that `MyClass` was a keyword in `VB.Net`. Having never u...
Does iteratee I/O make sense in non-functional languages?
In Haskell, [Iteratee based I/O](http://www.haskell.org/haskellwiki/Iteratee_I/O) seems very attractive. Iteratees are a composable, safe, fast ways of doing I/O inspired by the 'fold' a.k.a. 'reduce'...
how to make a webbrowser control go blank in c#?
Initially when the webbrowser is just loaded onto a form , it is blank(ie white color) . Once we go to a particular website , is there a way to make it go blank again . I tried going through the me...
- Modified
- 9 Sep at 16:15