c# Programming Glossary: this
Create Excel (.XLS and .XLSX) file from C# [closed] http://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c-sharp file solution is easy and is the current way I am handling this but I would like to control the output formats. EDIT I am still.. is here PEAR Excel Writer c# .net excel share improve this question You can use a library called ExcelLibrary. It's a.. Open a DB connection in this example with OleDB OleDbConnection con new OleDbConnection dbConnectionString..
How to properly clean up Excel interop objects http://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects null GC.Collect GC.WaitForPendingFinalizers Although this kind of works the Excel.exe process is still in the background.. disposed of. c# excel interop com interop share improve this question Excel does not quit because your app is still holding.. was not unloaded. I found the solution to my problem on this page which also has a nice rule for the usage of COM objects..
Encrypt/Decrypt string in .NET http://stackoverflow.com/questions/202011/encrypt-decrypt-string-in-net C# c# .net encryption mono cryptography share improve this question EDIT 2013 Oct Although I've edited this answer over.. improve this question EDIT 2013 Oct Although I've edited this answer over time to address shortcomings please see jbtule's..
Why are mutable structs evil? http://stackoverflow.com/questions/441309/why-are-mutable-structs-evil remark that mutable structs are evil like in the answer to this question . What's the actual problem with mutability and structs.. structs c# struct immutability mutable share improve this question Structs are value types which means they are copied..
Random number generator only generating one random number http://stackoverflow.com/questions/767999/random-number-generator-only-generating-one-random-number value. Why does that happen c# random share improve this question Every time you do new Random it is initialized using.. Random appRandom new ThreadLocal Random new Random this is then per thread so you don't need to synchronize. share..
Deep cloning objects in C# http://stackoverflow.com/questions/78536/deep-cloning-objects-in-c-sharp not reflected in the original object. I don't often need this functionality so when it's been necessary I've resorted to creating.. in the original object c# .net clone share improve this question Whilst the standard practice is to implement the ICloneable.. to have the following signature public static T Clone T this T source ... Now the method call simply becomes objectBeingCloned.Clone..
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 CODE 1 UserContrl1_LoadDataMethod if textbox1.text MyName This gives exception Load data corresponding to MyName . Populate..
Create Excel (.XLS and .XLSX) file from C# [closed] http://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c-sharp open source library posted on Google Code ExcelLibrary This looks to be a port of the PHP ExcelWriter that you mentioned..
Encrypt/Decrypt string in .NET http://stackoverflow.com/questions/202011/encrypt-decrypt-string-in-net documentation and the MCTS Training Kit . EDIT 2012 April This answer was edited to pre pend the IV per jbtule's suggestion..
String vs string in C# [duplicate] http://stackoverflow.com/questions/215255/string-vs-string-in-c-sharp the class. e.g. string greet String.Format Hello 0 place This is the style that Microsoft tends to use in their examples ...
How to force my .NET App to run as administrator on Windows 7? http://stackoverflow.com/questions/2818179/how-to-force-my-net-app-to-run-as-administrator-on-windows-7 to modify the manifest that gets embedded in the program. This works on VS2008 and higher Project Add New Item select Application..
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 convert Byte Array to Hexadecimal String and vice versa This is probably a common question over the Internet but I couldn't..
Dynamic LINQ OrderBy on IEnumerable<T> http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet the dynamic LINQ library you just need the code as below. This covers most common scenarios including nested properties. To..
Casting vs using the 'as' keyword in the CLR http://stackoverflow.com/questions/496096/casting-vs-using-the-as-keyword-in-the-clr and the exception correctly shows the type of bug. This will throw an exception if randomObject is non null and refers.. favour of as plus null check. They're all insanely fast. This simply will not be the bottleneck in your code unless you really..
When to use struct in C#? http://stackoverflow.com/questions/521298/when-to-use-struct-in-c it does not require initialization like a reference type. This is both the beauty and the bane of the value type. In order..
Proper use of the IDisposable interface http://stackoverflow.com/questions/538060/proper-use-of-the-idisposable-interface and free the memory associated with any unused objects. This will include your object and any managed objects you use e.g... to Finalize meaning it's safe to free managed resources. This internal method could be given some arbitrary name like CoreDispose..
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 are naturally exact decimals it's good to use decimal. This is usually suitable for any concepts invented by humans financial..
What's the difference between String and string? http://stackoverflow.com/questions/7074/whats-the-difference-between-string-and-string the class. e.g. string greet String.Format Hello 0 place This is the style that Microsoft tends to use in their examples ...
Random number generator only generating one random number http://stackoverflow.com/questions/767999/random-number-generator-only-generating-one-random-number time you do new Random it is initialized using the clock. This means that in a tight loop you get the same value lots of times...
What does the [Flags] Enum Attribute mean in C#? http://stackoverflow.com/questions/8447/what-does-the-flags-enum-attribute-mean-in-c declared this way will be Yellow 0 Green 1 Red 2 Blue 3. This will render it useless for use as flags. Here's an example of.. MyColor.Yellow Yellow has been set... Under the covers This works because you previously used multiples of two in you enumeration...
How to use HTML Agility pack http://stackoverflow.com/questions/846994/how-to-use-html-agility-pack body if bodyNode null Do something with bodyNode NB This code is an example only and not necessarily the best only approach... that has a complete reference for each of the objects. This is normally in the base folder of the solution. share improve..
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 only yielded creating checks by using exception handling. This is against my religion so I was wondering if anyone has a better..
Create “Hello Wold” WebSocket example http://stackoverflow.com/questions/10200910/create-hello-wold-websocket-example About to send data ws.send Hello World I WANT TO SEND THIS MESSAGE TO THE SERVER alert Message sent ws.onmessage function..
C# Get property value without creating instance? http://stackoverflow.com/questions/11162652/c-sharp-get-property-value-without-creating-instance disclaims any association with this horrible code. THIS CODE IS FOR FUN ONLY. USING IT WILL INCUR WAILING AND GNASHING..
In C#, why can't i test if a event handler is null anywhere outside of the class that it's defined? http://stackoverflow.com/questions/1246116/in-c-why-cant-i-test-if-a-event-handler-is-null-anywhere-outside-of-the-class EventArgs e CANONICAL WAY TO TEST EVENT. OF COURSE THIS WORKS. if SomeEvent null SomeEvent this e public class UseSomeEvent..
What is the best scripting language to embed in a C# desktop application? [closed] http://stackoverflow.com/questions/137933/what-is-the-best-scripting-language-to-embed-in-a-c-sharp-desktop-application to avoid bloatin this example to much we will just add THIS program to its references that way we don't need another project..
Using the instance version of CreateMap and Map with a WCF service? http://stackoverflow.com/questions/1668962/using-the-instance-version-of-createmap-and-map-with-a-wcf-service urlTemplate log.Error passed in urlTemplate THIS IS PERFECT log.Error I am now this.urlTemplate THIS IS PERFECT.. THIS IS PERFECT log.Error I am now this.urlTemplate THIS IS PERFECT protected override IList DTO.SalesPoint ResolveCore.. source log.Error in resolveCore this.urlTemplate THIS IS RETURNING THE WRONG VALUE TEMPORARY SOLUTION I have done..
Convert all first letter to upper case, rest lower for each word http://stackoverflow.com/questions/1943273/convert-all-first-letter-to-upper-case-rest-lower-for-each-word that I need to convert. Currently the text looks like THIS IS MY TEXT RIGHT NOW I want to convert it to This Is My Text.. c# asp.net regex share improve this question string s THIS IS MY TEXT RIGHT NOW s System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase..
XML Serialization and Inherited Types http://stackoverflow.com/questions/20084/xml-serialization-and-inherited-types to enable XML Serialization. summary remarks DO NOT USE THIS CONSTRUCTOR remarks public AbstractXmlSerializer Default Ctor..
SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the session http://stackoverflow.com/questions/2113498/sqlexception-from-entity-framework-new-transaction-is-not-allowed-because-ther newProduct _dbRiv.SaveChanges ### THIS BREAKS ### break Model #1 This model sits in a database..
Parallel.For(): Update variable outside of loop http://stackoverflow.com/questions/2774170/parallel-for-update-variable-outside-of-loop is only being accessed by one thread at a time DON'T DO THIS Parallel.For 0 data.Count i Interlocked.Add ref sum data i BUT.....
How should I model my code to maximize code re-use in this specific situation? http://stackoverflow.com/questions/3389588/how-should-i-model-my-code-to-maximize-code-re-use-in-this-specific-situation in each implementation. private void SendMessagesToVendor THIS CODE CHANGES EACH IMPLEMENTATION vendor specific code goes..
multimap in .NET http://stackoverflow.com/questions/380595/multimap-in-net and or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY SOLUTIONS DESIGN ``AS IS'' AND ANY EXPRESS.. OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE...
C# Active Directory: Get domain name of user? http://stackoverflow.com/questions/4249139/c-sharp-active-directory-get-domain-name-of-user domain string ldapRoot.Properties defaultNamingContext 0 THIS IS WHERE I HIT THE COMEXCEPTION logger.Debug Retrieved 'defaultNamingContext'..
LINQ Expression to return Property value? http://stackoverflow.com/questions/567963/linq-expression-to-return-property-value Group g Parameters g.Select x x.Parameter .SelectMany g THIS PART FAILS MISERABLY items.Where item g.Parameters.Contains.. x.CustomerID 5 ids Console.WriteLine cust.CompanyName THIS IS THE INTERESTING BIT public static class QueryableChunked..
Most efficient way to check if an object is a value type http://stackoverflow.com/questions/5748661/most-efficient-way-to-check-if-an-object-is-a-value-type way to check if an object is a value type WARNING THIS CODE SUCKS SEE ANTHONY'S COMMENTS Which is faster 1. public..
foreach + break vs linq FirstOrDefault performance difference http://stackoverflow.com/questions/8214055/foreach-break-vs-linq-firstordefault-performance-difference 06.02. Lookup classes... Iteration 1028ms Linq 4517ms THIS IS THE PROBLEM BitCounter 401ms Manual loops... Iter 786ms Linq..
Field Initializer in C# Class not Run when Deserializing http://stackoverflow.com/questions/9419743/field-initializer-in-c-sharp-class-not-run-when-deserializing HIERARCHY DataContract public abstract class MyAbstract THIS INITIALIZER IS NOT RUN WHILE DESERIALIZING protected readonly..
|