¡@

Home 

c# Programming Glossary: then

Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on

http://stackoverflow.com/questions/142003/cross-thread-operation-not-valid-control-accessed-from-a-thread-other-than-the

As per SilverHorse's update comment the solution you want then should look like UserContrl1_LOadDataMethod string name if textbox1.InvokeRequired..

Deserialize JSON into C# dynamic object?

http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object

to have a dependency upon the System.Web.Helpers assembly then as Vlad points out you can use the built in methods of the Json.. you cannot assume the client environment includes this DLL then the above approach is a good alternative. EDIT 3 Extension to..

Why is it important to override GetHashCode when Equals method is overridden?

http://stackoverflow.com/questions/371328/why-is-it-important-to-override-gethashcode-when-equals-method-is-overridden

the rules are if two things are equal Equals ... true then they must return the same value for GetHashCode if the GetHashCode..

Why are mutable structs evil?

http://stackoverflow.com/questions/441309/why-are-mutable-structs-evil

copies which might be around. If your struct is immutable then all automatic copies resulting from being passed by value will..

Casting vs using the 'as' keyword in the CLR

http://stackoverflow.com/questions/496096/casting-vs-using-the-as-keyword-in-the-clr

a local variable. It's possible for the if to pass but then the cast to fail if another thread changes the value of randomObject.. of TargetType i.e. if it's not that means there's a bug then casting is the right solution. That throws an exception immediately.. instance of TargetType and TargetType is a reference type then use code like this TargetType convertedRandomObject randomObject..

Use of Application.DoEvents()

http://stackoverflow.com/questions/5181777/use-of-application-doevents

already completed. If that doesn't bomb with an exception then surely the data is scrambled all to hell. Back to ShowDialog..

Proper use of the IDisposable interface

http://stackoverflow.com/questions/538060/proper-use-of-the-idisposable-interface

called from Dispose If I'm being called from Finalize then the objects might not exist anymore if itIsSafeToAlsoFreeManagedObjects.. object descends from an object that implements Dispose then don't forget to call their base Dispose method when you overrode.. you can do better If the user calls Dispose on your object then everything has been cleaned up. Later on when the garbage collector..

Random number generator only generating one random number

http://stackoverflow.com/questions/767999/random-number-generator-only-generating-one-random-number

Random appRandom new ThreadLocal Random new Random this is then per thread so you don't need to synchronize. share improve..

Deep cloning objects in C#

http://stackoverflow.com/questions/78536/deep-cloning-objects-in-c-sharp

and fill a new object myObject newObj myObj.Clone And then make changes to the new object that are not reflected in the.. been necessary I've resorted to creating a new object and then copying each property individually but it always leaves me with.. stream The idea is that it serializes your object and then deserializes it into a fresh object. The benefit is that you..

How do you get total amount of RAM the computer has?

http://stackoverflow.com/questions/105031/how-do-you-get-total-amount-of-ram-the-computer-has

bool GlobalMemoryStatusEx In Out MEMORYSTATUSEX lpBuffer Then use like ulong installedMemory MEMORYSTATUSEX memStatus new..

ASP.NET MVC Custom Error Handling Application_Error Global.asax?

http://stackoverflow.com/questions/1171035/asp-net-mvc-custom-error-handling-application-error-global-asax

String.Format ~ Error 0 message 1 action exception.Message Then your controller will receive whatever you want GET Error HttpError404..

Public Fields versus Automatic Properties

http://stackoverflow.com/questions/1180860/public-fields-versus-automatic-properties

to look at it so I went rogue and used public fields. Then along comes C# 3.0 and I see they added automatic properties..

How to check for file lock?

http://stackoverflow.com/questions/1304/how-to-check-for-file-lock

look like this if not locked then open and update file Then between the two lines another process could easily lock the..

How to stop BackgroundWorker on Form's Closing event?

http://stackoverflow.com/questions/1731384/how-to-stop-backgroundworker-on-forms-closing-event

set a flag to indicate that the user requested a close. Then check that flag in the BGW's RunWorkerCompleted event handler..

How do I create a custom membership provider for ASP.NET MVC 2?

http://stackoverflow.com/questions/2771094/how-do-i-create-a-custom-membership-provider-for-asp-net-mvc-2

username password CurrentTerritoryID Then I connected that provider to my ASP.NET MVC 2 project by adding..

WPF image resources

http://stackoverflow.com/questions/347614/wpf-image-resources

x Key MyImageSource UriSource .. Media Image.png Then in your code use something like Image Source StaticResource..

ASP.NET MVC $.post call returning string…need help with format for jqGrid

http://stackoverflow.com/questions/4101116/asp-net-mvc-post-call-returning-string-need-help-with-format-for-jqgrid

string and the name of this Method is GetAllDestinations . Then your action used by dataUrl can look like public JsonResult..

Split List into Sublists with LINQ

http://stackoverflow.com/questions/419019/split-list-into-sublists-with-linq

by three has the effect of grouping them into groups of 3. Then convert each group to a list and the IEnumerable of List to..

C# String enums

http://stackoverflow.com/questions/424366/c-sharp-string-enums

_value value public string Value get return _value Then I can add this attribute to my enumerator public enum AuthenticationMethod..

How to embed a text file in a .NET assembly?

http://stackoverflow.com/questions/433171/how-to-embed-a-text-file-in-a-net-assembly

middle of the tab page click it to create a new resource. Then from the toolbar above the tab page select to add a new text..

How can I create a Product Key for my C# App

http://stackoverflow.com/questions/453030/how-can-i-create-a-product-key-for-my-c-sharp-app

date name of the user if you want to bind it to a user . Then encrypt that using some crypto algorithm with a fixed key or.. using some crypto algorithm with a fixed key or hash it. Then you just verify it within your program. One way to distribute..

How do I suspend painting for a control and its children?

http://stackoverflow.com/questions/487661/how-do-i-suspend-painting-for-a-control-and-its-children

SendMessage Target.Handle WM_SETREDRAW 1 0 If Redraw Then Target.Refresh End If End Sub Extension Public Sub SuspendDrawing..

Proper use of the IDisposable interface

http://stackoverflow.com/questions/538060/proper-use-of-the-idisposable-interface

What if the person forgot to call Dispose on your object Then they would leak some unmanaged resources Note They won't leak..

Random row from Linq to Sql

http://stackoverflow.com/questions/648196/random-row-from-linq-to-sql

used by our C# code... throw new NotImplementedException Then just order by ctx.Random this will do a random ordering at the..

How to associate a file extension to the current executable in C#

http://stackoverflow.com/questions/69761/how-to-associate-a-file-extension-to-the-current-executable-in-c-sharp

a unique name for your file type such as Acme.TextFile . Then create another key under HKEY_CLASSES_ROOT with the name set..

“The Controls collection cannot be modified because the control contains code blocks”

http://stackoverflow.com/questions/778952/the-controls-collection-cannot-be-modified-because-the-control-contains-code-bl

expressions aren't code blocks the CLR won't complain. Then in the code for the master page you'd add the following protected..

How to use HTML Agility pack

http://stackoverflow.com/questions/846994/how-to-use-html-agility-pack

in the HTMLAgilityPack Debug or Realease bin folder. Then as an example HtmlAgilityPack.HtmlDocument htmlDoc new HtmlAgilityPack.HtmlDocument..

Nullable types and the ternary operator: why is `? 10 : null` forbidden? [duplicate]

http://stackoverflow.com/questions/858080/nullable-types-and-the-ternary-operator-why-is-10-null-forbidden

bool GetBoolValue Do some logic and return true or false Then in another method something like this int x GetBoolValue 10..

Pivot Table in c#

http://stackoverflow.com/questions/1069677/pivot-table-in-c-sharp

SELECT FROM Pivot GO SELECT Year SUM CASE Quarter WHEN 1 THEN Amount ELSE 0 END AS Q1 SUM CASE Quarter WHEN 2 THEN Amount.. 1 THEN Amount ELSE 0 END AS Q1 SUM CASE Quarter WHEN 2 THEN Amount ELSE 0 END AS Q2 SUM CASE Quarter WHEN 3 THEN Amount.. 2 THEN Amount ELSE 0 END AS Q2 SUM CASE Quarter WHEN 3 THEN Amount ELSE 0 END AS Q3 SUM CASE Quarter WHEN 4 THEN Amount..

How can I use Entity Framework on an object graph past a depth of 2 with MySQL Connector / NET?

http://stackoverflow.com/questions/11676513/how-can-i-use-entity-framework-on-an-object-graph-past-a-depth-of-2-with-mysql-c

AS Description4 CASE WHEN Join3 . ShipId IS NULL THEN NULL WHEN Join3 . CrewMemberId IS NULL THEN NULL ELSE 1 END.. ShipId IS NULL THEN NULL WHEN Join3 . CrewMemberId IS NULL THEN NULL ELSE 1 END AS C1 CASE WHEN Join3 . ShipId IS NULL THEN.. NULL ELSE 1 END AS C1 CASE WHEN Join3 . ShipId IS NULL THEN NULL ELSE 1 END AS C2 FROM Harbor AS Extent1 LEFT OUTER JOIN..

Parsing Performance (If, TryParse, Try-Catch)

http://stackoverflow.com/questions/150114/parsing-performance-if-tryparse-try-catch

practices write your test cases run your application THEN benchmark and optimize. We should forget about small efficiencies..

When using Trusted_Connection=true and SQL Server authentication, will this effect performance?

http://stackoverflow.com/questions/1642483/when-using-trusted-connection-true-and-sql-server-authentication-will-this-effe

SSPI or Integrated Security true in your connection string THEN and only then you have Windows Authentication happening. Any..

Determine if internet connection is available

http://stackoverflow.com/questions/1859799/determine-if-internet-connection-is-available

that advice. I would rather detect a network change and THEN ping my service to check if it is online. .NET provides two..

Proper way to stop TcpListener

http://stackoverflow.com/questions/365370/proper-way-to-stop-tcplistener

blocking call it will at minimum take the next client and THEN exit. Is there any way to force it to simply break out and stop..

Quickest way in C# to find a file in a directory with over 20,000 files

http://stackoverflow.com/questions/714101/quickest-way-in-c-sharp-to-find-a-file-in-a-directory-with-over-20-000-files

of this will vary but searching for directories first THEN getting to files should help a lot Update Ok I did a quick bit..

linq case statement

http://stackoverflow.com/questions/936028/linq-case-statement

osc_products.products_quantity CASE WHEN itempromoflag 'N' THEN 100000 WHEN itemcat1 IN '1' '2' '31' AND itemsalestatus 'S'.. WHEN itemcat1 IN '1' '2' '31' AND itemsalestatus 'S' THEN 100000 WHEN itemsalestatus 'O' THEN 0 ELSE cds_oeinvitem.itemqtyonhand.. AND itemsalestatus 'S' THEN 100000 WHEN itemsalestatus 'O' THEN 0 ELSE cds_oeinvitem.itemqtyonhand cds_oeinvitem.itemqtycommitted..