¡@

Home 

c# Programming Glossary: here

Should Usings be inside or outside the namespace

http://stackoverflow.com/questions/125319/should-usings-be-inside-or-outside-the-namespace

my using statements should be inside the namespace. Is there a technical reason for putting the using statements inside instead.. stylecop code organization share improve this question There is actually a subtle difference between the two. Imagine you.. Math might be a bad name for a user defined class since there's already one in System the point here is just that there is..

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

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

modern versions of Excel support. The PEAR Excel Writer is here PEAR Excel Writer c# .net excel share improve this question.. works only for Excel 2007 2010 format files .xlsx files . There are a few known bugs with each library as noted in the comments...

What is the correct way to create a single instance application?

http://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application

Encrypt/Decrypt string in .NET

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

pre pend the IV per jbtule's suggestion and as illustrated here http msdn.microsoft.com en us library system.security.cryptography.aesmanaged..

Dependency Inject (DI) “friendly” library

http://stackoverflow.com/questions/2045904/dependency-inject-di-friendly-library

class design principles as much as possible. As such there will probably be classes intended for consumers to use directly.. point. This is called the Composition Root . More details here Where should I do dependency injection with Ninject 2 Design.. This is called the Composition Root . More details here Where should I do dependency injection with Ninject 2 Design Where..

Best way to copy between two Stream instances

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

best way to copy the contents of one stream to another Is there a standard utility method for this c# stream copying share.. copying share improve this question From .NET 4.5 on there is the Stream.CopyToAsync method input.CopyToAsync output This.. completed like so await input.CopyToAsync output Code from here on will be run in a continuation. Note that depending on where..

Randomize a List<T> in C#

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

silly flaw in my comparison. They are of course right. There's nothing wrong with System.Random if it's used in the way it.. on a really useful comment received today from @weston here on SO. Program.cs using System using System.Collections.Generic..

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

string hex BitConverter.ToString ba return hex.Replace There are even more variants of doing it for example here . The reverse.. There are even more variants of doing it for example here . The reverse conversion would go like this public static byte..

Deserialize JSON into C# dynamic object?

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

JSON into C# dynamic object Is there a way to deserialize JSON content into a C# 4 dynamic type It.. RTM. An alternative deserialisation approach is suggested here . I modified the code slightly to fix a bug and suit my coding..

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

Why are mutable structs evil?

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

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

Casting vs using the 'as' keyword in the CLR

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

or object type conversion. What I'd like to know is if there is a difference between these two methods of conversion public.. Implementation _MyObj new MyClass What is the difference here _myCls1 MyClass _MyObj _myCls2 _MyObj as MyClass If there is.. here _myCls1 MyClass _MyObj _myCls2 _MyObj as MyClass If there is a difference is there a cost difference or how does this..

When to use struct in C#?

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

together into a cohesive whole. I came across these rules here cached A struct should represent a single value. A struct should.. usage I sought some extra learning from Microsoft and here is what I found Consider defining a structure instead of a class.. reference type IEnumerator is returned. What we don't see here is any attempt or proof of requirement to keep structs immutable..

Difference between Property and Field in C# 3.0+

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

i don't need validation and want to use public get set is there any difference except the style future development ones like.. instance you've just defined a variable in the first there is a getter setter around the variable. So if you decide you.. question if you want to ignore the other suggestions here the other reason is that it's simply not good OO design. And..

Random number generator only generating one random number

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

min max Edit see comments why do we need a lock here Basically Next is going to change the internal state of the.. does not make any guarantees of thread safety. Thus there are two valid approaches synchronize so that we don't access..

Deep cloning objects in C#

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

but it always leaves me with the feeling that there is a better or more elegant way of handling the situation. How.. is to implement the ICloneable interface described here so I won't regurgitate here's a nice deep clone object copier.. ICloneable interface described here so I won't regurgitate here's a nice deep clone object copier I found on The Code Project..

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

there a way to check if a file is in use I'm writing a program in..

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

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

may have some support Pivot table issue in ExcelLibrary Here are a couple links for quick reference ExcelLibrary GNU Lesser.. Lesser GPL EPPlus GNU Library General Public License LGPL Here some example code for ExcelLibrary Here is an example taking.. License LGPL Here some example code for ExcelLibrary Here is an example taking data from a database and creating a workbook..

What is the correct way to create a single instance application?

http://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application

existed. c# .net wpf mutex share improve this question Here is a very good article regarding the Mutex solution. The approach..

Creating a byte array from a stream

http://stackoverflow.com/questions/221925/creating-a-byte-array-from-a-stream

method for creating a byte array from an input stream Here is my current solution with .NET 3.5. Stream s byte b using..

Creating application shortcut in a directory

http://stackoverflow.com/questions/234231/creating-application-shortcut-in-a-directory

shortcut.Description My Shorcut Name Here shortcut.DisplayMode ShellLink.LinkDisplayMode.edmNormal shortcut.Save..

Why .NET String is immutable? [duplicate]

http://stackoverflow.com/questions/2365272/why-net-string-is-immutable

guarantee gain . Copy on write is a middle ground. Here the real class holds a reference to a state class. State classes..

Using AES encryption in C#

http://stackoverflow.com/questions/273452/using-aes-encryption-in-c-sharp

public static void Main try string original Here is some data to encrypt Create a new instance of the RijndaelManaged..

How to Deserialize XML document

http://stackoverflow.com/questions/364253/how-to-deserialize-xml-document

xml deserialization share improve this question Here's a working version. I changed the XmlElementAttribute labels.. the stream . I also took a few liberties with the naming . Here are the classes Serializable public class Car System.Xml.Serialization.XmlElement..

Parsing JSON using Json.net

http://stackoverflow.com/questions/401756/parsing-json-using-json-net

and I'm confused as to how to accomplish what I need. Here is the format for the JSON I need to parse through. displayFieldName..

Regarding IE9 WebBrowser control

http://stackoverflow.com/questions/4612255/regarding-ie9-webbrowser-control

you have to set your registry like the earlier answer. Here is a reg file fragment for FEATURE_BROWSER_EMULATION Windows.. FEATURE_BROWSER_EMULATION contoso.exe dword 00002328 Here is the complete set of codes 9999 0x270F Internet Explorer 9...

Protect .NET code from reverse engineering?

http://stackoverflow.com/questions/506282/protect-net-code-from-reverse-engineering

pirated before and I took it as a personal affront. Here I was a small time developer pouring my heart and soul into..

When to use struct in C#?

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

instancing a struct is quicker than a reference type. Here I have a Dictionary int int that stores 300 000 random integers..

Fastest Way of Inserting in Entity Framework

http://stackoverflow.com/questions/5940225/fastest-way-of-inserting-in-entity-framework

by step. So it is helpful to clear it after some time. Here are a few measurements for my 560.000 entities commitCount 1..

How do I convert Word files to PDF programmatically?

http://stackoverflow.com/questions/607669/how-do-i-convert-word-files-to-pdf-programmatically

c# vb.net pdf ms word share improve this question Here is a modification of a program that worked for me. It uses Word..

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

scientific data would usually be represented in this form. Here the original values won't be decimally accurate to start with..

Retrieving Property name from lambda expression

http://stackoverflow.com/questions/671968/retrieving-property-name-from-lambda-expression

the Property name when passed in via a lambda expression Here is what i currently have. eg. GetSortingInfo User u u.UserId.. thing to make a type safe OnPropertyChanged method. Here's a method that'll return the PropertyInfo object for the expression...

Is it possible to dynamically compile and execute C# code fragments?

http://stackoverflow.com/questions/826398/is-it-possible-to-dynamically-compile-and-execute-c-sharp-code-fragments

constructing bits of code or even whole classes. Here's a nice short example take from LukeH's blog which uses some.. to dynamically load the assembly and execute it. Here is another example in C# that although slightly less concise..

C# Finalize/Dispose pattern

http://stackoverflow.com/questions/898828/c-sharp-finalize-dispose-pattern

GC.SuppressFinalize this Question about the source code Here I have not added the finalizer. And normally the finalizer will..

Visual Studio : executing clean up code when debugging stops

http://stackoverflow.com/questions/1033441/visual-studio-executing-clean-up-code-when-debugging-stops

How can I measure the similarity between 2 strings?

http://stackoverflow.com/questions/1034622/how-can-i-measure-the-similarity-between-2-strings

Compare string text1 string text2 DO SOMETHING HERE TO COMPARE Examples First String StackOverflow Second String..

WPF Button Mouseover Image

http://stackoverflow.com/questions/12271916/wpf-button-mouseover-image

BACKGROUND Setter Property Background Value WHAT GOES HERE TargetName border Trigger ControlTemplate.Triggers ControlTemplate..

How do you retrieve a list of logged-in/connected users in .NET?

http://stackoverflow.com/questions/132620/how-do-you-retrieve-a-list-of-logged-in-connected-users-in-net

static void Main string args ListUsers INSERT SERVERNAME HERE public static IntPtr OpenServer String Name IntPtr server WTSOpenServer..

Thread Control.Invoke

http://stackoverflow.com/questions/1423446/thread-control-invoke

But When I run it in ShowAllFly function cbFly.Items.Clear HERE Gives ERROR LIKE Control.Invoke must be used to interact with..

MVVM Light & WPF - Binding Multiple instances of a Window to a ViewModel

http://stackoverflow.com/questions/16993433/mvvm-light-wpf-binding-multiple-instances-of-a-window-to-a-viewmodel

approach is a bit long and is very well documented HERE Mixture of question and answer . Hence why I ignored it for..

SetWindowsHookEx in C#

http://stackoverflow.com/questions/1811383/setwindowshookex-in-c-sharp

typeof Form1 .Module HERE IS THE PROBLEM. WHAT THE HECK DO I PASS INTO THE LAST 2 PARAMS..

Why C# doen't support multiple inheritance [duplicate]

http://stackoverflow.com/questions/2865302/why-c-sharp-doent-support-multiple-inheritance

How the StringBuilder class is implemented? Does it internally create new string objects each time we append?

http://stackoverflow.com/questions/3564906/how-the-stringbuilder-class-is-implemented-does-it-internally-create-new-string

int m_MaxCapacity internal volatile string m_StringValue HERE private const string MaxCapacityField m_MaxCapacity private.. const int DefaultCapacity 0x10 internal char m_ChunkChars HERE internal int m_ChunkLength internal int m_ChunkOffset internal..

Global hotkey in console application

http://stackoverflow.com/questions/3654787/global-hotkey-in-console-application

the hotkey notification and raise an event. The code HERE demonstrates the principal. HERE is an article on handling messages.. raise an event. The code HERE demonstrates the principal. HERE is an article on handling messages in a Console application..

An attempt was made to access a socket in a way forbidden by its access permissions

http://stackoverflow.com/questions/4799651/an-attempt-was-made-to-access-a-socket-in-a-way-forbidden-by-its-access-permissi

from the Graph API dynamic me app.Api me EXCEPTION THROWN HERE ViewData FirstName me.first_name ViewData LastName me.last_name..

How to get current page URL in MVC 3

http://stackoverflow.com/questions/5304782/how-to-get-current-page-url-in-mvc-3

900px margin auto div id fb root div fb comments href URL HERE num_posts 10 width 900 fb comments div What is the best way..

How to trigger event when a variable's value is changed?

http://stackoverflow.com/questions/5842339/how-to-trigger-event-when-a-variables-value-is-changed

set _myProperty value if _myProperty 1 DO SOMETHING HERE This allows you to run some code any time the property value..

ebay api - returning auctions ending later than 10 days

http://stackoverflow.com/questions/6929259/ebay-api-returning-auctions-ending-later-than-10-days

SERVICE VERSION 1.11.0 SECURITY APPNAME ENTER APP ID HERE RESPONSE DATA FORMAT XML categoryId 307 paginationInput.entriesPerPage.. SERVICE VERSION 1.11.0 SECURITY APPNAME ENTER APP ID HERE RESPONSE DATA FORMAT XML categoryId 307 paginationInput.entriesPerPage..

.NET - Convert Generic Collection to DataTable

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

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

CORS Support within WCF REST Services

http://stackoverflow.com/questions/7234599/cors-support-within-wcf-rest-services

page dies some day. I hate finding Your answer is right HERE links and then the link is dead. behaviors endpointBehaviors..

Padding is invalid and cannot be removed?

http://stackoverflow.com/questions/8583112/padding-is-invalid-and-cannot-be-removed

exml.DecryptData edElement alg I GET THE EXCEPTION HERE Replace the encryptedData element with the plaintext XML element...