¡@

Home 

c# Programming Glossary: if

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

The user control does some heavy data operation such that if I directly call the UserControl_Load method the UI become nonresponsive.. load method execution. To overcome this I load data on different thread trying to change existing code as little as I can.. which will be loading the data and when done will notify the application that it has done its work. Now came a real..

Encrypt/Decrypt string in .NET

http://stackoverflow.com/questions/202011/encrypt-decrypt-string-in-net

EncryptStringAES string plainText string sharedSecret if string.IsNullOrEmpty plainText throw new ArgumentNullException.. plainText throw new ArgumentNullException plainText if string.IsNullOrEmpty sharedSecret throw new ArgumentNullException.. finally Clear the RijndaelManaged object. if aesAlg null aesAlg.Clear Return the encrypted bytes from the..

Dynamic LINQ OrderBy on IEnumerable<T>

http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet

return IOrderedQueryable T result Edit it gets more fun if you want to mix that with dynamic although note that dynamic.. CallSite Func CallSite object object callSites name if callSite null callSites name callSite CallSite Func CallSite.. dynamic object accessor Func dynamic object accessors name if accessor null lock accessors accessor Func dynamic object..

Why are mutable structs evil?

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

means they are copied when they are passed around. So if you change a copy you are changing only that copy not the original..

Random number generator only generating one random number

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

I step that loop with the debugger during runtime I get different values which is what I want . However if I put a breakpoint.. I get different values which is what I want . However if I put a breakpoint two lines below that code all members of.. and we could also start getting the same numbers from different threads which might be a problem and might not. The guarantee..

Deep cloning objects in C#

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

or deep copy an object so that the cloned object can be modified without any changes being reflected in the original object.. copied object. returns public static T Clone T T source if typeof T .IsSerializable throw new ArgumentException The type.. a null object simply return the default for that object if Object.ReferenceEquals source null return default T IFormatter..

Randomize a List<T> in C#

http://stackoverflow.com/questions/273313/randomize-a-listt-in-c-sharp

candidates. It's fast but not as random as it should be. If you need a better quality of randomness in your shuffles use..

Deserialize JSON into C# dynamic object?

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

them as they aren't required for deserialisation. EDIT 2 If you are happy to have a dependency upon the System.Web.Helpers..

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

a custom IEqualityComparer T to group items into buckets. If the hash code for two items does not match they may never be.. return FooId is a suitable GetHashCode implementation. If you are testing multiple properties it is common to combine..

Why are mutable structs evil?

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

original and not any other copies which might be around. If your struct is immutable then all automatic copies resulting.. resulting from being passed by value will be the same. If you want to change it you have to consciously do it by creating..

Casting vs using the 'as' keyword in the CLR

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

here _myCls1 MyClass _MyObj _myCls2 _MyObj as MyClass If there is a difference is there a cost difference or how does.. thread changes the value of randomObject between the two. If randomObject really should be an instance of TargetType i.e... TargetType convertedRandomObject TargetType randomObject If randomObject might be an instance of TargetType and TargetType..

Use of Application.DoEvents()

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

resumes trying to finish a job that was already completed. If that doesn't bomb with an exception then surely the data is..

Creating a blocking Queue<T> in .NET?

http://stackoverflow.com/questions/530211/creating-a-blocking-queuet-in-net

a queue and multiple threads reading from the same queue. If the queue reaches a specific size all threads that are filling..

Proper use of the IDisposable interface

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

to call DeleteHandle . Note What is an unmanaged resource If you found it in the Microsoft .NET Framework it's managed. If.. you found it in the Microsoft .NET Framework it's managed. If you went poking around MSDN yourself it's unmanaged. Anything.. sitting open waiting for the GC to finalize the object. If the user has called Dispose meaning they no longer plan to use..

Random number generator only generating one random number

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

x mac x byte Misc.RandomNumber int 0xFFFF int 0xFFFFFF 256 If I step that loop with the debugger during runtime I get different.. going to change the internal state of the Random instance. If we do that at the same time from multiple threads you could..

What does the [Flags] Enum Attribute mean in C#?

http://stackoverflow.com/questions/8447/what-does-the-flags-enum-attribute-mean-in-c

does not automatically make the enum values powers of two. If you omit the numeric values the enum will not work as one might..

How do I find the lat/long that is x km north of a given lat/long

http://stackoverflow.com/questions/1125144/how-do-i-find-the-lat-long-that-is-x-km-north-of-a-given-lat-long

point 1 if lat asin sin lat1 cos d cos lat1 sin d cos tc IF cos lat 0 lon lon1 endpoint a pole ELSE lon mod lon1 asin sin.. ELSE lon mod lon1 asin sin tc sin d cos lat pi 2 pi pi ENDIF And this is my C# translation. Extend a Point North South by..

C# object is not null but (myObject != null) still return false

http://stackoverflow.com/questions/155458/c-sharp-object-is-not-null-but-myobject-null-still-return-false

. In step by step when debugging it doesn't go inside the IF statement... When I do a Quick Watch with these following expression..

Single-assembly multi-language Windows Forms deployment (ILMerge and satellite assemblies / localization) - possible?

http://stackoverflow.com/questions/1952638/single-assembly-multi-language-windows-forms-deployment-ilmerge-and-satellite-a

1TempProg.exe 1InputProg.exe 1es InputProg.resources.dll IF ERRORLEVEL NEQ 0 GOTO END ProgramFiles Microsoft ILMerge ILMerge.exe.. 1TempProg.exe 1fr InputProg.resources.dll IF ERRORLEVEL NEQ 0 GOTO END del 1InputProg.exe del 1InputProg.pdb..

Sharing sessions across applications using the ASP.NET Session State Service

http://stackoverflow.com/questions/2868316/sharing-sessions-across-applications-using-the-asp-net-session-state-service

Provider is the default application name for .NET apps IF @connStrAppName '.NET SQLClient Data Provider' SET @appName..

multimap in .NET

http://stackoverflow.com/questions/380595/multimap-in-net

ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions..

Is there any significant difference between using if/else and switch-case in C#?

http://stackoverflow.com/questions/395618/is-there-any-significant-difference-between-using-if-else-and-switch-case-in-c

accepted SWITCH statement only produces same assembly as IFs in debug or compatibility mode. In release it will be compiled.. so most often such switch will be compiled into stack of IFs. But if number of conditions is big enough to cover overheads.. faster than comparing to each string constant in IFs. To sum it up if number of conditions is more than 5 or so..

Expression Tree Copy or Convert

http://stackoverflow.com/questions/4601844/expression-tree-copy-or-convert

Show Console in Windows Application?

http://stackoverflow.com/questions/472282/show-console-in-windows-application

a pointer to the forground window. The idea here is that IF the user is starting our application from an existing console..

SQL Server (2008) Pass ArrayList or String to SP for IN()

http://stackoverflow.com/questions/519769/sql-server-2008-pass-arraylist-or-string-to-sp-for-in

SELECT @start_index 1 WHILE @index DATALENGTH @list BEGIN IF SUBSTRING @list @index 1 ' ' BEGIN SELECT @id CAST SUBSTRING..

How do I maintain RichText formatting (bold/italic/etc) when changing any one element?

http://stackoverflow.com/questions/5325918/how-do-i-maintain-richtext-formatting-bold-italic-etc-when-changing-any-one-el

styles are selected Parameters style eg FontStyle.Bold add IF true then add else remove throw error if style isn't bold italic..

Convert generic List/Enumerable to DataTable?

http://stackoverflow.com/questions/564366/convert-generic-list-enumerable-to-datatable

thing that i can imagine is use Reflection to do this. IF i have this List Whatever whatever new List Whatever This next..

Implementing Audit Log / Change History with MVC & Entity Framework

http://stackoverflow.com/questions/6867459/implementing-audit-log-change-history-with-mvc-entity-framework

mvc entity framework audit share improve this question IF you are using EF 4 you can subscribe to the SavingChanges event...

Using MediaElement to play video from Stream

http://stackoverflow.com/questions/7117589/using-mediaelement-to-play-video-from-stream

c# wpf wcf mediaelement share improve this question IF you can make the WCF deliver the Media Object via a http URL..

Itextsharp: Adjust 2 elements on exactly one page

http://stackoverflow.com/questions/7590071/itextsharp-adjust-2-elements-on-exactly-one-page

document.Add t The table is successfully added but IF the size of the image fits the page size of the document then..

Activate existing browser window with given URL from C# application (without triggering reload)

http://stackoverflow.com/questions/878429/activate-existing-browser-window-with-given-url-from-c-sharp-application-withou

winforms share improve this question This will work IF the user has that site active in their browser. If they're using..

Memcached on Windows (x64)

http://stackoverflow.com/questions/8896/memcached-on-windows-x64

on Windows x64 Does anyone know IF WHEN or HOW I can get Memcached running on a Windows 64bit environment..

publishing asp.net application to the internet

http://stackoverflow.com/questions/9509022/publishing-asp-net-application-to-the-internet

the IP address and another that only has the IP address. IF for some reason it warns you about duplicate bindings go to..

using various types in a using statement (C#)

http://stackoverflow.com/questions/966086/using-various-types-in-a-using-statement-c

finally dispose why does it accept multiple objects ONLY IF THEY ARE OF THE SAME TYPE I don't get it since all they need..

Simplify Overriding Equals(), GetHashCode() in C# for Better Maintainability

http://stackoverflow.com/questions/9707918/simplify-overriding-equals-gethashcode-in-c-sharp-for-better-maintainabilit

31 return base.GetHashCode ^ ^ is a good combiner IF the combined values are well distributed MyIntProp.GetHashCode..