c# Programming Glossary: just
Should Usings be inside or outside the namespace http://stackoverflow.com/questions/125319/should-usings-be-inside-or-outside-the-namespace since there's already one in System the point here is just that there is a difference and it affects the maintainability..
Dependency Inject (DI) “friendly” library http://stackoverflow.com/questions/2045904/dependency-inject-di-friendly-library has to do to create all these unimportant dependencies just to get to the real classes they want to use. My current thinking.. Patterns but it should always be your real goal . DI is just a means to achieve that end . Apply the Hollywood Principle..
Best way to copy between two Stream instances http://stackoverflow.com/questions/230128/best-way-to-copy-between-two-stream-instances subject to change still sequences reads and writes it just doesn't waste a threads blocking on I O completion . From .NET..
Dynamic LINQ OrderBy on IEnumerable<T> http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet oldie... To do this without the dynamic LINQ library you just need the code as below. This covers most common scenarios including..
Case insensitive 'Contains(string)' http://stackoverflow.com/questions/444798/case-insensitive-containsstring sensitivity.. Currently I UPPERCASE them both but that's just silly. UPDATE The sillyness I refer to is the i18n issues that..
Casting vs using the 'as' keyword in the CLR http://stackoverflow.com/questions/496096/casting-vs-using-the-as-keyword-in-the-clr go. If you really don't need the converted value but you just need to know whether it is an instance of TargetType then the..
Protect .NET code from reverse engineering? http://stackoverflow.com/questions/506282/protect-net-code-from-reverse-engineering that is runnable is vulnerable. What you want to do is just make it difficult enough to crack to make it not worth peoples'.. license code can be undone with a single byte patch. You just need to accept that there is a very real chance people are going..
Use of Application.DoEvents() http://stackoverflow.com/questions/5181777/use-of-application-doevents run code in a different order. It will execute predictably just like it did when you tested your code. It makes dialogs extremely..
Creating a blocking Queue<T> in .NET? http://stackoverflow.com/questions/530211/creating-a-blocking-queuet-in-net perhaps something like a bool flag if set an empty queue just returns rather than blocking bool closing public void Close..
Proper use of the IDisposable interface http://stackoverflow.com/questions/538060/proper-use-of-the-idisposable-interface There was even an interface created IDisposable that has just that one method public interface IDisposable void Dispose So.. free it. But do you really want to leave 250MB of memory just sitting there waiting for the garbage collector to eventually.. doesn't know or care about your Dispose method. That was just a name we chose for a method we call when we want to get rid..
Difference between Property and Field in C# 3.0+ http://stackoverflow.com/questions/653536/difference-between-property-and-field-in-c-sharp-3-0 question Encapsulation. In the second instance you've just defined a variable in the first there is a getter setter around..
Random number generator only generating one random number http://stackoverflow.com/questions/767999/random-number-generator-only-generating-one-random-number the same time from multiple threads you could argue we've just made the outcome even more random but what we are actually doing.. single instance from multiple callers at the same time is just asking for trouble. The lock achieves the first and simpler..
Is it possible to dynamically compile and execute C# code fragments? http://stackoverflow.com/questions/826398/is-it-possible-to-dynamically-compile-and-execute-c-sharp-code-fragments example take from LukeH's blog which uses some LINQ too just for fun. using System using System.Collections.Generic using.. code on the fly. If you want to then run the code you just need to use a bit of reflection to dynamically load the assembly..
How slow are .NET exceptions? http://stackoverflow.com/questions/161942/how-slow-are-net-exceptions cache so I don't see that as a particularly good argument. Just to make it clear I don't support using exceptions where they're..
TransactionScope automatically escalating to MSDTC on some machines? http://stackoverflow.com/questions/1690892/transactionscope-automatically-escalating-to-msdtc-on-some-machines just smells of global SqlConnection instance. Pew Update 3 Just to clarify up here in the question SQL2008 Allows multiple connections..
When should I use a List vs a LinkedList http://stackoverflow.com/questions/169973/when-should-i-use-a-list-vs-a-linkedlist where you plan to insert the item then use a linked list. Just because you have to insert a lot of items it does not make it..
Embedding JavaScript engine into .NET (C#) http://stackoverflow.com/questions/172753/embedding-javascript-engine-into-net-c implemented don't worry it's not a client side code Just to clarify I'm not trying to actually program the application..
Unsubscribe anonymous method in C# http://stackoverflow.com/questions/183367/unsubscribe-anonymous-method-in-c-sharp I did it MyEvent myDelegate .... later MyEvent myDelegate Just keep a reference to the delegate around. share improve this..
Does using “new” on a strict allocate it on the heap or stack? http://stackoverflow.com/questions/203695/does-using-new-on-a-strict-allocate-it-on-the-heap-or-stack once and then the same storage location is reused. EDIT Just to be clear this is only true in some cases... in particular..
Getting the size of a field in bytes with C# http://stackoverflow.com/questions/207592/getting-the-size-of-a-field-in-bytes-with-c-sharp as it sounds but I've used it to good effect before now. Just yesterday I was thinking it would be a good idea to write a.. to that class. And again padding can make a difference. Just to clarify what I mean about padding being relevant consider..
Best Practice for Forcing Garbage Collection in C# http://stackoverflow.com/questions/233596/best-practice-for-forcing-garbage-collection-in-c-sharp Collect won't have a negative impact then go ahead... Just try to make sure objects are cleaned up when you no longer need..
C# Captured Variable In Loop http://stackoverflow.com/questions/271440/c-sharp-captured-variable-in-loop of this problem is using for or foreach for int i 0 i 10 i Just one variable foreach string x in foo And again despite how it..
Cannot delete directory with Directory.Delete(path, true) http://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true you delete them. Otherwise that will raise an exception. Just slap this code into your project. public static void DeleteDirectory..
Entity Framework 4 - AddObject vs Attach http://stackoverflow.com/questions/3920111/entity-framework-4-addobject-vs-attach What am i missing here When do we need to use Attach EDIT Just to clarify i'm looking for examples of when to use Attach over..
Best practices for exception management in Java or C# http://stackoverflow.com/questions/409563/best-practices-for-exception-management-in-java-or-c-sharp should only catch exceptions that you can actually handle. Just catching exceptions is not the right thing to do in most cases...
Dynamic LINQ OrderBy on IEnumerable<T> http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet T c# linq linq to objects share improve this question Just stumbled into this oldie... To do this without the dynamic LINQ..
DateTime vs DateTimeOffset http://stackoverflow.com/questions/4331189/datetime-vs-datetimeoffset particular represent it in calendar time with a DateTime . Just be sure you don't ever confuse one calendar with another. Unspecified..
Differences in string compare methods in C# http://stackoverflow.com/questions/44288/differences-in-string-compare-methods-in-c-sharp Object.ReferenceEquals stringValue otherStringValue Just checks that references are the same ie. it isn't just two strings..
.NET String to byte Array C# http://stackoverflow.com/questions/472906/net-string-to-byte-array-c-sharp certainly do NOT need to worry about encodings for this. Just do this instead static byte GetBytes string str byte bytes new..
When to use struct in C#? http://stackoverflow.com/questions/521298/when-to-use-struct-in-c integers while resizing 15 times during the operation. Just out of curiosity what would the total time to fill be if I already..
Create code first, many to many, with additional fields in association table http://stackoverflow.com/questions/7050404/create-code-first-many-to-many-with-additional-fields-in-association-table fetch the comments automatically behind the scenes. Edit Just for fun a few examples more how to add entities and relationships..
Why catch and rethrow Exception in C#? http://stackoverflow.com/questions/881473/why-catch-and-rethrow-exception-in-c throw is a no op. Cheers all. Thanx for your time. EDIT Just to summarise for anyone who finds this thread in future... DO..
|