c# Programming Glossary: always
decimal vs double! - Which one should I use and when? [duplicate] http://stackoverflow.com/questions/1165761/decimal-vs-double-which-one-should-i-use-and-when decimal money share improve this question For money always decimal. It's why it was created. If numbers must add up correctly..
Virtual member call in a constructor http://stackoverflow.com/questions/119506/virtual-member-call-in-a-constructor most derived type. This means that virtual method calls always run on the most derived type. When you combine these two facts..
Volatile vs. Interlocked vs. lock http://stackoverflow.com/questions/154551/volatile-vs-interlocked-vs-lock it for A good example is say you have 2 threads one which always writes to a variable say queueLength and one which always reads.. always writes to a variable say queueLength and one which always reads from that same variable. If queueLength is not volatile.. use volatile. This would ensure that thread B will always see the most up to date thing that thread A has written. Note..
TransactionScope automatically escalating to MSDTC on some machines? http://stackoverflow.com/questions/1690892/transactionscope-automatically-escalating-to-msdtc-on-some-machines 2615.aspx from 2005 talks about how escalation to DTC will always happen when connecting to SQL2000. We're using SQL2005 2008..
Dependency Inject (DI) “friendly” library http://stackoverflow.com/questions/2045904/dependency-inject-di-friendly-library from memory though from Design Patterns but it should always be your real goal . DI is just a means to achieve that end ... resulting API becomes too complex for novice users you can always provide a few Facade classes that encapsulate common dependency..
Why .NET String is immutable? [duplicate] http://stackoverflow.com/questions/2365272/why-net-string-is-immutable the fact that a reference to such a string will always equal abc throughout its lifetime which does require immutability..
Tips for optimizing C#/.NET programs [closed] http://stackoverflow.com/questions/2473666/tips-for-optimizing-c-net-programs their active server pages their VB their C# code. I always resist this. Emphasizing tips and tricks is exactly the wrong..
What is the difference between a field and a property in C#? http://stackoverflow.com/questions/295104/what-is-the-difference-between-a-field-and-a-property-in-c question Properties expose fields. Fields should almost always be kept private to a class and accessed via get and set properties...
How to read a text file reversely with iterator in C# http://stackoverflow.com/questions/452902/how-to-read-a-text-file-reversely-with-iterator-in-c-sharp UTF 8 sequences could trigger this. For UTF 8 we should always see a valid character start in every 3 bytes and if this is..
Best way to parse command line arguments in C#? [closed] http://stackoverflow.com/questions/491595/best-way-to-parse-command-line-arguments-in-c that you use Patterns that you use Assume the commands always adhere to common standards such as answered here . c# .net..
VS2010 does not show unhandled exception message in a WinForms Application on a 64-bit version of Windows http://stackoverflow.com/questions/4933958/vs2010-does-not-show-unhandled-exception-message-in-a-winforms-application-on-a The unfortunately disables Edit Continue and might not always be possible when you have a dependency on 32 bit code. Other..
How do I get the path of the assembly the code is in? http://stackoverflow.com/questions/52797/how-do-i-get-the-path-of-the-assembly-the-code-is-in which are located relative to the dll. I want the path to always resolve correctly regardless of whether the testing dll is run..
What is differences between Multidimensional array and Array of Arrays in C#? http://stackoverflow.com/questions/597720/what-is-differences-between-multidimensional-array-and-array-of-arrays-in-c multidimensional arrays are method invocations which are always slower. Consider the following methods static void SetElementAt..
Difference between Property and Field in C# 3.0+ http://stackoverflow.com/questions/653536/difference-between-property-and-field-in-c-sharp-3-0 And if you don't have a very good reason for doing it always choose a property over a public variable field. share improve..
Deep cloning objects in C# http://stackoverflow.com/questions/78536/deep-cloning-objects-in-c-sharp object and then copying each property individually but it always leaves me with the feeling that there is a better or more elegant..
C# Events and Thread Safety http://stackoverflow.com/questions/786383/c-sharp-events-and-thread-safety . And yes there's certainly a race condition but there always will be. Suppose we just change the code to TheEvent this EventArgs.Empty.. fix the race condition. It also doesn't guarantee that you always see the latest value of the variable. share improve this answer..
What does the [Flags] Enum Attribute mean in C#? http://stackoverflow.com/questions/8447/what-does-the-flags-enum-attribute-mean-in-c AND operation to test for a flag because the result is always zero. However you can perform a logical not a bitwise comparison..
Difference Between Equals and == http://stackoverflow.com/questions/971954/difference-between-equals-and the types of a and b are reference types In Java will always compare for identity i.e. whether the two values are references..
Why is Graphics.MeasureString() returning a higher than expected number? http://stackoverflow.com/questions/1203087/why-is-graphics-measurestring-returning-a-higher-than-expected-number to contract by up to an em. To avoid these problems Always pass MeasureString and DrawString a StringFormat based on the..
How to start unit testing or TDD? http://stackoverflow.com/questions/1365943/how-to-start-unit-testing-or-tdd reference much else. Then start writing some tests. Always ask yourself what do I want to try and prove with this test..
Parsing Performance (If, TryParse, Try-Catch) http://stackoverflow.com/questions/150114/parsing-performance-if-tryparse-try-catch c# parsing text share improve this question Always use T.TryParse string str out T value . Throwing exceptions..
Is it better to return null or empty collection? http://stackoverflow.com/questions/1969993/is-it-better-to-return-null-or-empty-collection share improve this question Empty collection. Always. This sucks if myInstance.CollectionProperty null foreach var..
Hash and salt passwords in C# http://stackoverflow.com/questions/2138429/hash-and-salt-passwords-in-c-sharp i if array1 i array2 i return false return true Always use a new salt per password. Salts do not have to be kept secret..
Algorithm to avoid SQL injection on MSSQL Server from C# code? http://stackoverflow.com/questions/249567/algorithm-to-avoid-sql-injection-on-mssql-server-from-c-sharp-code as much as is possible about the database from the public. Always write code that handles exceptions or empty datasets in a vanilla.. them clueless. And #11 always revisit revise this list. Always be up to date. Be proactive. Make it an upfront priority and..
Bring a window to the front in WPF http://stackoverflow.com/questions/257587/bring-a-window-to-the-front-in-wpf should do the trick unless I misunderstood and you want Always on Top behavior. In that case you want myWindow.TopMost true..
How does this regex find triangular numbers? http://stackoverflow.com/questions/3627681/how-does-this-regex-find-triangular-numbers Flavor notes Not all flavors support nested references. Always familiarize yourself with the quirks of the flavor that you're..
Is it considered acceptable to not call Dispose() on a TPL Task object? http://stackoverflow.com/questions/3734280/is-it-considered-acceptable-to-not-call-dispose-on-a-tpl-task-object The MSDN documentation on the Task.Dispose method says Always call Dispose before you release your last reference to the Task...
Re-entrant locks in C# http://stackoverflow.com/questions/391913/re-entrant-locks-in-c-sharp when you have to be careful. Pay particular attention to Always acquire locks on a given number of objects in the same sequence... locks on a given number of objects in the same sequence. Always release locks in the reverse sequence to how you acquire them...
Creating a DPI-Aware Application http://stackoverflow.com/questions/4075802/creating-a-dpi-aware-application correctly without a FlowLayoutPanel or TableLayoutPanel Always edit design your apps in default 96 DPI 100 . If you design..
Why does (does it really?) List<T> implement all these interfaces, not just IList<T>? http://stackoverflow.com/questions/4817369/why-does-does-it-really-listt-implement-all-these-interfaces-not-just-ilis interfaces are stated in the base type list Yes. Always Almost always interface I1 interface I2 I1 interface I3 I2 It..
Best way to specify whitespace in a String.Split operation http://stackoverflow.com/questions/6111298/best-way-to-specify-whitespace-in-a-string-split-operation true if they are passed to the Char.IsWhiteSpace method. Always always always read the documentation share improve this answer..
Are floating-point numbers consistent in C#? Can they be? http://stackoverflow.com/questions/6683059/are-floating-point-numbers-consistent-in-c-can-they-be _controlfp_s Windows _FPU_SETCW Linux or fpsetprec BSD . Always run the same compiler with the same optimization settings and..
C# Events and Thread Safety http://stackoverflow.com/questions/786383/c-sharp-events-and-thread-safety Thread Safety I frequently hear read the following advice Always make a copy of an event before you check it for null and fire..
Problems with DeploymentItem attribute http://stackoverflow.com/questions/883270/problems-with-deploymentitem-attribute Output Folder setting in VS.NET. You need this to be Copy Always or similar in order to get the files into the output folder...
ExecuteReader requires an open and available Connection. The connection's current state is Connecting http://stackoverflow.com/questions/9705637/executereader-requires-an-open-and-available-connection-the-connections-curren objects at all. Don't make them static shared in VB.NET Always create open in case of Connections use close and dispose them..
WPF WebBrowser (3.5 SP1) Always on top - other suggestion to display HTML in WPF http://stackoverflow.com/questions/980334/wpf-webbrowser-3-5-sp1-always-on-top-other-suggestion-to-display-html-in-wpf WebBrowser 3.5 SP1 Always on top other suggestion to display HTML in WPF I've been desperately..
How to Generate Unique Public and Private Key via RSA http://stackoverflow.com/questions/1307204/how-to-generate-unique-public-and-private-key-via-rsa Encrypt export etc. finally rsa.PersistKeyInCsp false ALWAYS Update Want to see for yourself Use this tools http www.jensign.com..
Debug.Assert vs Exception Throwing http://stackoverflow.com/questions/1467568/debug-assert-vs-exception-throwing situations. For me the key difference is this It should ALWAYS be possible to produce a test case which exercises a given throw..
C# keyword usage virtual+override vs. new http://stackoverflow.com/questions/159978/c-sharp-keyword-usage-virtualoverride-vs-new Daigle So if you are doing real polymorphism you SHOULD ALWAYS OVERRIDE . The only place where you need to use new is when..
Stopwatch in a Task seems to be additive across all tasks, want to measure just task interval http://stackoverflow.com/questions/16239220/stopwatch-in-a-task-seems-to-be-additive-across-all-tasks-want-to-measure-just ms then the results appear in output out of initial order ALWAYS in order of increasing duration of tasks the 1st in output the..
A Real Timespan Object With .Years & .Months http://stackoverflow.com/questions/1916358/a-real-timespan-object-with-years-months days ago . The amount of days in both these scenarios will ALWAYS be different even though the statement is exactly the same...
Is it better to return null or empty collection? http://stackoverflow.com/questions/1969993/is-it-better-to-return-null-or-empty-collection return null when returning a collection or enumerable. ALWAYS return an empty enumerable collection. It prevents the aforementioned..
C# Thread Termination and Thread.Abort() http://stackoverflow.com/questions/2251964/c-sharp-thread-termination-and-thread-abort Calling this method usually terminates the thread. Why not ALWAYS In which cases it doesn't termenate the thread Are there any..
Static constructor can run after the non-static constructor. Is this a compiler bug? http://stackoverflow.com/questions/2925611/static-constructor-can-run-after-the-non-static-constructor-is-this-a-compiler Non Static because I thought the static constructor was ALWAYS called before the non static constructor. I tested this with..
Does the C# “finally” block ALWAYS execute? [duplicate] http://stackoverflow.com/questions/3216046/does-the-c-sharp-finally-block-always-execute the C# &ldquo finally&rdquo block ALWAYS execute duplicate Possible Duplicate Will code in a Finally..
How to do the processing and keep GUI refreshed using databinding? http://stackoverflow.com/questions/4522583/how-to-do-the-processing-and-keep-gui-refreshed-using-databinding it works it is minimalistic it is ugly though and it ALWAYS slows down computation even if no GUI is there based on Jon..
C# DllImport with C++ boolean function not returning correctly http://stackoverflow.com/questions/4608876/c-sharp-dllimport-with-c-boolean-function-not-returning-correctly bool Exist string name Yet whenever I call my function it ALWAYS returns true even when I commented out my little function and..
Database Deployment Strategies (SQL Server) http://stackoverflow.com/questions/504909/database-deployment-strategies-sql-server second issue is that we have 4 test databases and they are ALWAYS out of line and the only way to truly line them back up is to..
Prevent .NET Garbage collection for short period of time http://stackoverflow.com/questions/6005865/prevent-net-garbage-collection-for-short-period-of-time deferred except in extremely low memory situations finally ALWAYS set the latency mode back GCSettings.LatencyMode oldMode That..
Using Statements vs Namespace path? C# http://stackoverflow.com/questions/6628531/using-statements-vs-namespace-path-c-sharp There is zero performance difference because the compiler ALWAYS puts in the full name using is only a hint for the compiler..
How to find the actual printable area? (PrintDocument) http://stackoverflow.com/questions/8761633/how-to-find-the-actual-printable-area-printdocument a preview or a real document. printAction e.PrintAction We ALWAYS want true here as we will implement the margin limitations later..
How A Month is defined in the rest of the world? [closed] http://stackoverflow.com/questions/8820603/how-a-month-is-defined-in-the-rest-of-the-world that respect but differs from yours in that the month will ALWAYS be advanced cf your case of 1 Jan to 31 Jan . share improve..
Why does it appear that my random number generator isn't random in C#? http://stackoverflow.com/questions/932520/why-does-it-appear-that-my-random-number-generator-isnt-random-in-c problem is that I've run it more than 100 times and it's ALWAYS giving me the same answer when my min 0 and max 1. I get 0 every..
|