¡@

Home 

c# Programming Glossary: so

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

Windows Forms C# .NET There is a main form which hosts some user control. The user control does some heavy data operation.. form which hosts some user control. The user control does some heavy data operation such that if I directly call the UserControl_Load.. the usercontrol I'm fetching data based on the values of some control like textbox on userControl. The pseudocode would..

Create Excel (.XLS and .XLSX) file from C# [closed]

http://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c-sharp

an Excel Spreadsheet with C# Ideally I would like open source so I don't have to add any third party dependencies to my.. Excel Spreadsheet with C# Ideally I would like open source so I don't have to add any third party dependencies to my code.. to create the file using OLE Automation. The .CSV file solution is easy and is the current way I am handling this but..

Randomize a List<T> in C#

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

number generator in System.Security.Cryptography like so using System.Security.Cryptography ... public static void Shuffle.. T value list k list k list n list n value A simple comparison is available at http thegrenade.blogspot.com 2010 02 when random.. written to me to point out the big silly flaw in my comparison. They are of course right. There's nothing wrong with System.Random..

How do you convert Byte Array to Hexadecimal String, and vice versa?

http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa

for long strings by using a single pass parser like so public static byte StringToByteArray String hex int NumberChars..

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

using code like below to reduce diagonal collisions i.e. so that new Foo 3 5 has a different hash code to new Foo 5 3 int.. ... return hash Oh for convenience you might also consider providing and operators when overriding Equals and..

WebBrowser Control in a new thread

http://stackoverflow.com/questions/4269800/webbrowser-control-in-a-new-thread

is the thread end before the document is fully loaded so I never get to make use of the DocumentComplete event. How can.. public static void Click object o var url UriItem o Console.WriteLine @ Clicking url.Link var clicker new WebBrowser ScriptErrorsSuppressed.. e var br sender as WebBrowser if br.Url e.Url Console.WriteLine Natigated to 0 e.Url Application.ExitThread Stops..

Casting vs using the 'as' keyword in the CLR

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

I moved it up here at the suggestion of Michael Haren. Also I want to thank everyone who's provided insight and perspective.. improve this question I don't think any of the answers so far at the time of starting this answer have really explained.. which. Don't do this Bad code checks type twice for no reason if randomObject is TargetType TargetType foo TargetType randomObject..

Use of Application.DoEvents()

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

and the language supports mutating a struct if that's so bad Same reason you shoot yourself in the foot if you don't.. supports mutating a struct if that's so bad Same reason you shoot yourself in the foot if you don't do it right. Easily... ShowDialog . It executes DoEvents but do note that it does something else. It disables all the windows in the application..

Creating a blocking Queue<T> in .NET?

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

on add until an item is removed from the queue. The solution below is what I am using right now and my question is.. looks very unsafe very little synchronization how about something like class SizeQueue T private readonly Queue T queue.. item edit In reality you'd want a way to close the queue so that readers start exiting cleanly perhaps something like a..

Proper use of the IDisposable interface

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

of the IDisposable interface is to clean up unmanaged resources. To me unmanaged means things like database connections.. To me unmanaged means things like database connections sockets window handles etc. But I've seen code where the Dispose.. where the Dispose method is implemented to free managed resources which seems redundant to me since the garbage collector..

What is the difference between Decimal, Float and Double in C#?

http://stackoverflow.com/questions/618535/what-is-the-difference-between-decimal-float-and-double-in-c

between Decimal Float and Double in C# When would someone use one of these c# .net floating point double decimal.. representable in binary floating point 0.1 for example so if you use a binary floating point value you'll actually get.. original values won't be decimally accurate to start with so it's not important for the expected results to maintain the..

Random number generator only generating one random number

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

breaking the internal implementation and we could also start getting the same numbers from different threads which.. safety. Thus there are two valid approaches synchronize so that we don't access it at the same time from different threads..

Deep cloning objects in C#

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

cloning objects in C# I want to do something like myObject myObj GetmyObj Create and fill a new object.. the original object. I don't often need this functionality so when it's been necessary I've resorted to creating a new object.. need this functionality so when it's been necessary I've resorted to creating a new object and then copying each property..

Is there a way to check if a file is in use?

http://stackoverflow.com/questions/876473/is-there-a-way-to-check-if-a-file-is-in-use

by using exception handling. This is against my religion so I was wondering if anyone has a better way of doing it c# file.. file is not locked return false Edit Please check all the solutions here. Some of them are great share improve this answer..

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

thread. I'm not going to do it ever from a child thread. So only accessing the value so that the corresponding data can..

How to properly clean up Excel interop objects

http://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects

of COM objects in C# Never use 2 dots with com objects. So with this knowledge the right way of doing the above is Worksheets..

Simple 2 way encryption for C#

http://stackoverflow.com/questions/165808/simple-2-way-encryption-for-c-sharp

in character values that cannot be passed in a URL. So instead I just lay out all of the byte values in a long string..

String vs string in C# [duplicate]

http://stackoverflow.com/questions/215255/string-vs-string-in-c-sharp

this question string is an alias for System.String . So technically there is no difference. It's like int vs. System.Int32..

Deserialize JSON into C# dynamic object?

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

dynamic obj serializer.Deserialize json typeof object So given a JSON string Items Name Apple Price 12.3 Name Grape Price..

What C# mocking framework to use? [closed]

http://stackoverflow.com/questions/37359/what-c-sharp-mocking-framework-to-use

Moles Commercial included with Visual Studio 2012 Ultimate So my question is what one is your favourite .NET mocking framework.. s s.GetCustomers .Returns new List Customer @Ngu Soon Hui I wasn't aware that the other frameworks don't have compile..

Why are mutable structs evil?

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

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

Best way to parse command line arguments in C#? [closed]

http://stackoverflow.com/questions/491595/best-way-to-parse-command-line-arguments-in-c

get more complicated the parsing can get pretty ugly. So I'm interested in Libraries that you use Patterns that you use..

Casting vs using the 'as' keyword in the CLR

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

does this affect my program Hopefully this makes sense. Sorry for the bad example it is all I could think of... Update.. aren't going to do anything with the values afterwards. So let's not worry about the performance. Let's worry about correctness..

When to use struct in C#?

http://stackoverflow.com/questions/521298/when-to-use-struct-in-c

total time to fill be if I already knew the capacity 13ms So now what if Entry were a class Would these times or metrics.. executes the default constructor on each array element. Some compilers such as the C# compiler do not allow structures..

Proper use of the IDisposable interface

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

by MyCollection any faster than it normally would edit So far people have posted some good examples of using IDisposable.. that one method public interface IDisposable void Dispose So you make your object expose the IDisposable interface and that.. get rid of those wasteful bitmaps and database connections So now we will get rid of unmanaged resources because we have to..

What is the best workaround for the WCF client `using` block issue?

http://stackoverflow.com/questions/573872/what-is-the-best-workaround-for-the-wcf-client-using-block-issue

resources that implement IDisposable using var client new SomeWCFServiceClient Do something with the client But as noted.. override the client's Dispose method wherever you use it. Something like public partial class SomeWCFServiceClient IDisposable.. wherever you use it. Something like public partial class SomeWCFServiceClient IDisposable void IDisposable.Dispose if this.State..

Using .NET, how can you find the mime type of a file based on the file signature not the extension

http://stackoverflow.com/questions/58510/using-net-how-can-you-find-the-mime-type-of-a-file-based-on-the-file-signature

Usually only the first 256 bytes of data are significant. So read the first up to 256 bytes from the file and pass it to..

Difference between Property and Field in C# 3.0+

http://stackoverflow.com/questions/653536/difference-between-property-and-field-in-c-sharp-3-0

in the first there is a getter setter around the variable. So if you decide you want to validate the variable at a later date..

What's the difference between String and string?

http://stackoverflow.com/questions/7074/whats-the-difference-between-string-and-string

this question string is an alias for System.String . So technically there is no difference. It's like int vs. System.Int32..

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

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

looks like this myProperties.AllowedColors 00001110 So when you retreive the value you are actually bitwise AND'ing..

A Simple C# DLL - how do I call it from Excel, Access, VBA, VB6?

http://stackoverflow.com/questions/1170794/a-simple-c-sharp-dll-how-do-i-call-it-from-excel-access-vba-vb6

as to why how to get this working Thanks in advance SO c# excel dll vb6 interop share improve this question You..

How to secure an ASP.NET Web API

http://stackoverflow.com/questions/11775594/how-to-secure-an-asp-net-web-api

simple. It seems there are many questions like this on SO but no good answers. What is everybody doing in this space ..

Should I use public properties and private fields or public fields for data?

http://stackoverflow.com/questions/1277572/should-i-use-public-properties-and-private-fields-or-public-fields-for-data

public fields for data In much of the code I have seen on SO thecodeproject.com and I tend to do this in my own code I have..

Is there a downside to adding an anonymous empty delegate on event declaration?

http://stackoverflow.com/questions/170907/is-there-a-downside-to-adding-an-anonymous-empty-delegate-on-event-declaration

I have seen a few mentions of this idiom including on SO Deliberately empty subscriber public event EventHandler AskQuestion..

What's the point of the var keyword?

http://stackoverflow.com/questions/209199/whats-the-point-of-the-var-keyword

type declaration and I have read with interest the SO discussion of when it might be appropriate. I have also read..

Randomize a List<T> in C#

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

really useful comment received today from @weston here on SO. Program.cs using System using System.Collections.Generic using..

How to call a method daily, at specific time, in C#?

http://stackoverflow.com/questions/3243348/how-to-call-a-method-daily-at-specific-time-in-c

a method daily at specific time in C# I've searched on SO and found answers about Quartz.net. But it seems to be too big..

Benefits of using the conditional ?: (ternary) operator

http://stackoverflow.com/questions/3312786/benefits-of-using-the-conditional-ternary-operator

world of programming. I'm lucky enough to know about SO and have a friend who's been in the game since he was fairly..

Why can't I define a default constructor for a struct in .NET?

http://stackoverflow.com/questions/333829/why-cant-i-define-a-default-constructor-for-a-struct-in-net

to what you get if you call a normal constructor. See this SO question for a bit more on that aspect. I suspect that there..

How To Represent 0.1 In Floating Point Arithmetic And Decimal

http://stackoverflow.com/questions/3448777/how-to-represent-0-1-in-floating-point-arithmetic-and-decimal

as an IEEE754 float and provides so much opportunity on SO for people answering why doesn't 0.1 0.1 0.1 0.3 type questions..

Question about terminating a thread cleanly in .NET

http://stackoverflow.com/questions/3632149/question-about-terminating-a-thread-cleanly-in-net

what I am after. Thanks gang. Further reading All these SO responses assume the worker thread will loop. That doesn't sit..

Why are mutable structs evil?

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

mutable structs evil Following the discussions here on SO I already read several times the remark that mutable structs..

Get File Icon used by Shell

http://stackoverflow.com/questions/462270/get-file-icon-used-by-shell

and I thought it would be useful to have archived here on SO. c# .net vb.net shell icons share improve this question ..

Enum ToString

http://stackoverflow.com/questions/479410/enum-tostring

output these values in a user friendly way though. In this SO post there is a lot of code that I can't seem to compile.. I..

Generate a PDF that automatically prints

http://stackoverflow.com/questions/6167995/generate-a-pdf-that-automatically-prints

that shows the file. I found this other approach in this SO question that might worth trying html script language javascript..

Accessing a Shared File (UNC) From a Remote, Non-Trusted Domain With Credentials

http://stackoverflow.com/questions/659013/accessing-a-shared-file-unc-from-a-remote-non-trusted-domain-with-credentials

my searches have turned up nill. I therefore appeal to the SO community for help. The issue is this we have a need to programmatically.. for the lpLocalName and lpProvider. The dwType should be RESOURCETYPE_DISK. The lpRemoteName should be ComputerName. share..

Free obfuscation tools for .NET [closed]

http://stackoverflow.com/questions/805549/free-obfuscation-tools-for-net

this question Maybe Eazfuscator.NET Check out this SO question Best .NET obfuscation tools strategy Since June 29..

OCR for .NET [closed]

http://stackoverflow.com/questions/870280/ocr-for-net

an OCR component for .NET.I read all questions about it at SO but I couldn't find what I needed. The MODI function from MS..

Why catch and rethrow Exception in C#?

http://stackoverflow.com/questions/881473/why-catch-and-rethrow-exception-in-c

isn't it ... i.e they both refined C . I did search Both SO and google and failed to find an authorative answer to exactly..

How to render a formula in WPF or WinForms

http://stackoverflow.com/questions/8899204/how-to-render-a-formula-in-wpf-or-winforms

webpages online as well as a few similar questions on SO WPF Math an inactive WPF library for rendering math related..