¡@

Home 

c# Programming Glossary: for

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

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

I am handling this but I would like to control the output formats. EDIT I am still looking at these to see the best alternative.. I am still looking at these to see the best alternative for my solution. Interop will work but it requires Excel to be on.. achieve with CSV files. I will look more into the 2003 xml format but that also puts a Excel 2003 requirement on the file...

How to properly clean up Excel interop objects

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

I didn't know was that internally C# created a wrapper for the Worksheets COM object which didn't get released by my code.. to my problem on this page which also has a nice rule for the usage of COM objects in C# Never use 2 dots with com objects...

Encrypt/Decrypt string in .NET

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

time to address shortcomings please see jbtule's answer for a more robust informed solution. http stackoverflow.com a 10366194.. please see jbtule's answer for a more robust informed solution. http stackoverflow.com a 10366194 188474 Original.. param name sharedSecret A password used to generate a key for encryption. param public static string EncryptStringAES string..

Dynamic LINQ OrderBy on IEnumerable<T>

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

IEnumerable T I found an example in the VS2008 Examples for Dynamic LINQ that allows you to use a sql like string e.g. OrderBy.. you to use a sql like string e.g. OrderBy Name Age DESC for ordering. Unfortunately the method included only works on IQueryable.. sql like string e.g. OrderBy Name Age DESC for ordering. Unfortunately the method included only works on IQueryable T . Is..

Random number generator only generating one random number

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

random.Next min max How I call it byte mac new byte 6 for int x 0 x 6 x mac x byte Misc.RandomNumber int 0xFFFF int 0xFFFFFF.. from multiple callers at the same time is just asking for trouble. The lock achieves the first and simpler of these approaches..

Deep cloning objects in C#

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

KB tips SerializedObjectCloner.aspx Provides a method for performing a deep copy of an object. Binary Serialization is.. tips SerializedObjectCloner.aspx Provides a method for performing a deep copy of an object. Binary Serialization is used to.. deep copy of an object. Binary Serialization is used to perform the copy. summary public static class ObjectCopier summary..

Public Fields versus Automatic Properties

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

a value and doesn't require any computation to get or set. For these we would all do this number public class Book private..

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 thread it was created on I have a scenario. Windows Forms C# .NET There is a main form which hosts some user control... before you attempt to switch back to the control's thread. For example UserContrl1_LOadDataMethod if textbox1.text MyName Now..

Transitioning from Windows Forms to WPF

http://stackoverflow.com/questions/15681352/transitioning-from-windows-forms-to-wpf

from Windows Forms to WPF For a long time now I have been stuck with Windows.. from Windows Forms to WPF For a long time now I have been stuck with Windows Forms development.. to WPF For a long time now I have been stuck with Windows Forms development started with VB6 and has continued through to..

How to properly clean up Excel interop objects

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

excelSheet 0 excelSheet null GC.Collect GC.WaitForPendingFinalizers Although this kind of works the Excel.exe process.. member of a COM object without assigning it to a variable. For me it was the excelApp.Worksheets object which I directly used..

Read/Write 'Extended' file properties (C#)

http://stackoverflow.com/questions/220097/read-write-extended-file-properties-c

... c# extended properties share improve this question For those of not crazy about VB here it is in c# public static void..

Best way to copy between two Stream instances

http://stackoverflow.com/questions/230128/best-way-to-copy-between-two-stream-instances

on there's is the Stream.CopyTo method input.CopyTo output For .NET 3.5 and before There isn't anything baked into the framework..

How to use reflection to call generic Method?

http://stackoverflow.com/questions/232535/how-to-use-reflection-to-call-generic-method

myType generic.Invoke this null EDIT For a static method pass null as the first argument to Invoke ...

Why is lock(this) {…} bad?

http://stackoverflow.com/questions/251391/why-is-lockthis-bad

an unknown number of lock entry points hinders this. For example any one with a reference to the object can lock on it..

Deserialize JSON into C# dynamic object?

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

var name pair.Key if value is string sb.AppendFormat 0 1 name value else if value is IDictionary string object.. .ToString sb else if arrayValue is string sb.AppendFormat 0 arrayValue else sb.AppendFormat 0 arrayValue sb.Append.. is string sb.AppendFormat 0 arrayValue else sb.AppendFormat 0 arrayValue sb.Append else sb.AppendFormat 0 1 name..

What C# mocking framework to use? [closed]

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

awesome. The fluent interface makes it a joy to work with. For example mockService.Setup s s.GetCustomers .Returns new List..

Case insensitive 'Contains(string)'

http://stackoverflow.com/questions/444798/case-insensitive-containsstring

of case insensitivity which is language dependent . For example the English language uses the characters I and i for..

.NET String to byte Array C#

http://stackoverflow.com/questions/472906/net-string-to-byte-array-c-sharp

to be able to re construct the string from the bytes. For those goals I honestly do not understand why people keep telling..

Proper use of the IDisposable interface

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

the garbage collector should take care of that for you. For example public class MyCollection IDisposable private List String.. don't the machine grinds to a swapping halt. Bonus Reading For anyone who likes the style of this answer explaining the why..

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

exactly represented for example. As for what to use when For values which are naturally exact decimals it's good to use decimal... the score given to divers or ice skaters for example. For values which are more artefacts of nature which can't really.. measured exactly anyway float double are more appropriate. For example scientific data would usually be represented in this..

Sending email through Gmail SMTP server with C#

http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c-sharp

email through Gmail SMTP server with C# For some reason the accepted answer or any others don't work for..

Is there a reason for C#'s reuse of the variable in a foreach?

http://stackoverflow.com/questions/8898925/is-there-a-reason-for-cs-reuse-of-the-variable-in-a-foreach

have to be wary of the access to modified closure pitfall. For example foreach var s in strings query query.Where i i.Prop..

How do I calculate someone's age in C#?

http://stackoverflow.com/questions/9/how-do-i-calculate-someones-age-in-c

their age c# .net datetime share improve this question For some reason Jeff's code didn't seem simple enough. To me this..

C# Get property value without creating instance?

http://stackoverflow.com/questions/11162652/c-sharp-get-property-value-without-creating-instance

any association with this horrible code. THIS CODE IS FOR FUN ONLY. USING IT WILL INCUR WAILING AND GNASHING OF TEETH...

Sending an array of values to Oracle procedure to use in WHERE IN clause

http://stackoverflow.com/questions/13580245/sending-an-array-of-values-to-oracle-procedure-to-use-in-where-in-clause

PARAM_THAT_WILL_BE _USED_INSIDE_WHERE_IN AS BEGIN OPEN CUR FOR SELECT FROM MY_TABLE WHERE COL1 IN here I want to put values..

Authentication with old password no longer supported, use 4.1 style passwords

http://stackoverflow.com/questions/15772479/authentication-with-old-password-no-longer-supported-use-4-1-style-passwords

given solution SET SESSION old_passwords 0 SET PASSWORD FOR user@host PASSWORD 'your pw here' first query executed successfully.. by the Workbench SET SESSION old_passwords 0 SET PASSWORD FOR my_user PASSWORD 'my_password' After that I could connnect using..

ReSharper Warning - Access to Modified Closure [duplicate]

http://stackoverflow.com/questions/1688465/resharper-warning-access-to-modified-closure

for you in this non loop context. Imagine that you had a FOR loop and the if was inside it and the string declaration was..

Cannot set some HTTP headers when using System.Net.WebRequest

http://stackoverflow.com/questions/239725/cannot-set-some-http-headers-when-using-system-net-webrequest

properties on the object itself if they exist. Thanks FOR and Jvenema for the leading guidelines... But What i found out..

How to pre-load all deployed assemblies for an AppDomain

http://stackoverflow.com/questions/3021613/how-to-pre-load-all-deployed-assemblies-for-an-appdomain

string p S.O. NOTE ELIDED ALL EXCEPTION HANDLING FOR BREVITY get all .dll files from the specified path and load..

In .NET, which loop runs faster, 'for' or 'foreach'?

http://stackoverflow.com/questions/365615/in-net-which-loop-runs-faster-for-or-foreach

grand old article by Emmanuel Schanzer CodeProject FOREACH Vs. FOR Blog To foreach or not to foreach that is the question.. old article by Emmanuel Schanzer CodeProject FOREACH Vs. FOR Blog To foreach or not to foreach that is the question ASP.NET..

multimap in .NET

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

TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOLUTIONS.. NO EVENT SHALL SOLUTIONS DESIGN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL..

How do I check if a number is positive or negative in c#?

http://stackoverflow.com/questions/4099366/how-do-i-check-if-a-number-is-positive-or-negative-in-c

if a number is positive or negative Thanks. Edit APOLOGIES FOR MY QUESTION. I was very very tired I had a liquid lunch if you..

Count total rows of gridview with pagination

http://stackoverflow.com/questions/5788329/count-total-rows-of-gridview-with-pagination

AppListTbl.Rows.Count.ToString CANDIDATE S ARE ELIGIBLE FOR THE POST OF vacanyList.SelectedItem.Text.ToUpper . sendMailBtn.Visible.. snAppListTbl .Rows.Count.ToString CANDIDATE S ARE ELIGIBLE FOR THE POST OF vacanyList.SelectedItem.Text.ToUpper . appForVacGrid.PageIndex..

when not to use lambda expressions [closed]

http://stackoverflow.com/questions/672918/when-not-to-use-lambda-expressions

of foreach vs. List.ForEach .Net C# Loop Performance Test FOR FOREACH LINQ Lambda . DataTable.Select is faster than linq What.. foreach vs. List.ForEach .Net C# Loop Performance Test FOR FOREACH LINQ Lambda . DataTable.Select is faster than linq What..

.NET - Convert Generic Collection to DataTable

http://stackoverflow.com/questions/701223/net-convert-generic-collection-to-datatable

prop in properties HERE IS WHERE THE ERROR IS THROWN FOR NULLABLE TYPES table.Columns.Add prop.Name prop.PropertyType..

Writing large number of records (bulk insert) to Access in .NET/C#

http://stackoverflow.com/questions/7070011/writing-large-number-of-records-bulk-insert-to-access-in-net-c

using ACCESS Microsoft.Office.Interop.Access USED ONLY FOR THE TEXT FILE METHOD using DAO Microsoft.Office.Interop.Access.Dao.. using DAO Microsoft.Office.Interop.Access.Dao USED ONLY FOR THE DAO METHOD using System.Data USED ONLY FOR THE ADO.NET DataTable.. USED ONLY FOR THE DAO METHOD using System.Data USED ONLY FOR THE ADO.NET DataTable METHOD using System.Data.OleDb USED FOR..