c# Programming Glossary: example
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 you attempt to switch back to the control's thread. For example UserContrl1_LOadDataMethod if textbox1.text MyName Now it wont..
Create Excel (.XLS and .XLSX) file from C# [closed] http://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c-sharp EPPlus GNU Library General Public License LGPL Here some example code for ExcelLibrary Here is an example taking data from a.. LGPL Here some example code for ExcelLibrary Here is an example taking data from a database and creating a workbook from it... Open a DB connection in this example with OleDB OleDbConnection con new OleDbConnection dbConnectionString..
Encrypt/Decrypt string in .NET http://stackoverflow.com/questions/202011/encrypt-decrypt-string-in-net a 10366194 188474 Original Answer Here's a working example derived from the RijndaelManaged Class documentation and the..
Randomize a List<T> in C# http://stackoverflow.com/questions/273313/randomize-a-listt-in-c-sharp if it's used in the way it was intended. In my first example above I instantiate the rng variable inside of the Shuffle method.. is going to be called repeatedly. Below is a fixed full example based on a really useful comment received today from @weston..
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 hex.Replace There are even more variants of doing it for example here . The reverse conversion would go like this public static..
Deserialize JSON into C# dynamic object? http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object
Dynamic LINQ OrderBy on IEnumerable<T> http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet LINQ OrderBy on IEnumerable T I found an example in the VS2008 Examples for Dynamic LINQ that allows you to use..
Casting vs using the 'as' keyword in the CLR http://stackoverflow.com/questions/496096/casting-vs-using-the-as-keyword-in-the-clr my program Hopefully this makes sense. Sorry for the bad example it is all I could think of... Update What is in general the..
Use of Application.DoEvents() http://stackoverflow.com/questions/5181777/use-of-application-doevents about 3 feet in front of the monitor. The user could for example close the main window while the loop that calls DoEvents is..
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 exactly representable in binary floating point 0.1 for example so if you use a binary floating point value you'll actually.. result of dividing 1 by 3 can't be exactly represented for example. As for what to use when For values which are naturally exact.. invented by humans financial values are the most obvious example but there are others too. Consider the score given to divers..
What does the [Flags] Enum Attribute mean in C#? http://stackoverflow.com/questions/8447/what-does-the-flags-enum-attribute-mean-in-c Attribute mean in C# Anyone have a good explanation or example they could post Edit I changed the answer this one is more in.. are usually manipulated using bitwise operators for example myProperties.AllowedColors MyColor.Red MyColor.Green MyColor.Blue.. 3. This will render it useless for use as flags. Here's an example of a correct declaration Flags public enum MyColors Yellow 1..
How to use HTML Agility pack http://stackoverflow.com/questions/846994/how-to-use-html-agility-pack HTMLAgilityPack Debug or Realease bin folder. Then as an example HtmlAgilityPack.HtmlDocument htmlDoc new HtmlAgilityPack.HtmlDocument.. null Do something with bodyNode NB This code is an example only and not necessarily the best only approach. Do not use..
Making Entity Class Closed for Changes http://stackoverflow.com/questions/11425993/making-entity-class-closed-for-changes This interface can then also be on CreditCardPayment Example public interface IPayment int Id get set int PaymentId get set..
Transitioning from Windows Forms to WPF http://stackoverflow.com/questions/15681352/transitioning-from-windows-forms-to-wpf to WPF What is this DataContext you speak of A Simple MVVM Example To summarize the biggest difference between Winforms and WPF..
What's the best way of implementing a thread-safe Dictionary? http://stackoverflow.com/questions/157933/whats-the-best-way-of-implementing-a-thread-safe-dictionary SyncRoot object throughout my consumers multiple threads Example lock m_MySharedDictionary.SyncRoot m_MySharedDictionary.Add..
C# Lambda expression, why should I use this? http://stackoverflow.com/questions/167343/c-sharp-lambda-expression-why-should-i-use-this tree from a lambda instead of an anonymous delegate void Example Predicate int aDelegate called like Example x x 5 becomes void.. delegate void Example Predicate int aDelegate called like Example x x 5 becomes void Example Expression Predicate int expressionTree.. int aDelegate called like Example x x 5 becomes void Example Expression Predicate int expressionTree The latter will get..
What NoSQL solutions are out there for .NET? [closed] http://stackoverflow.com/questions/1777103/what-nosql-solutions-are-out-there-for-net of C# .NET Redis clients available and on NuGet . The Example below uses my ServiceStack's open source C# client . All the..
Expression Versus Statement http://stackoverflow.com/questions/19132/expression-versus-statement question Expression Something which evaluates to a value. Example 1 2 x Statement A line of code which does something. Example.. 1 2 x Statement A line of code which does something. Example GOTO 100 In the earliest general purpose programming languages..
How do I replace multiple spaces with a single space in C#? http://stackoverflow.com/questions/206717/how-do-i-replace-multiple-spaces-with-a-single-space-in-c multiple spaces in a string with only one space in C# Example 1 2 3 4 5 would be 1 2 3 4 5 c# regex string share improve..
String vs string in C# [duplicate] http://stackoverflow.com/questions/215255/string-vs-string-in-c-sharp is the difference between String and string note the case Example string s Hello World String S Hello World Also what are the..
How to use reflection to call generic Method? http://stackoverflow.com/questions/232535/how-to-use-reflection-to-call-generic-method at runtime Consider the following sample code inside the Example method what's the most concise way to invoke GenericMethod using.. in the myType variable public class Sample public void Example string typeName Type myType FindType typeName what goes here..
Linq Distinct on a particular Property http://stackoverflow.com/questions/489258/linq-distinct-on-a-particular-property a list of Object on ONE or MORE Properties of the object Example If an object is Person with Property Id . How can I get all..
How can I convert an integer into its verbal representation? http://stackoverflow.com/questions/554314/how-can-i-convert-an-integer-into-its-verbal-representation use to convert an integer to it's verbal representation Example input 4 567 788 Example output Four million Five hundred sixty.. to it's verbal representation Example input 4 567 788 Example output Four million Five hundred sixty seven thousand seven..
How to elevate privileges only when required? http://stackoverflow.com/questions/573086/how-to-elevate-privileges-only-when-required of application on some event such as press of a button . Example If user clicks this button then he is prompted with UAC dialog..
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 is probably through the administrative built in shares. Example computername c program files Folder file.txt Here is some sample..
What's the difference between String and string? http://stackoverflow.com/questions/7074/whats-the-difference-between-string-and-string is the difference between String and string note the case Example string s Hello World String S Hello World Also what are the..
How to implement custom JsonConverter in JSON.NET to deserialize a List of base class objects http://stackoverflow.com/questions/8030538/how-to-implement-custom-jsonconverter-in-json-net-to-deserialize-a-list-of-base the correct type by checking existance of certain fields. Example string json Department Department1 JobTitle JobTitle1 FirstName..
Quickest way to convert a base 10 number to any base in .NET? http://stackoverflow.com/questions/923771/quickest-way-to-convert-a-base-10-number-to-any-base-in-net its equivalent string representation in a specified base. Example string binary Convert.ToString 5 2 convert 5 to its binary representation..
The string was not recognized as a valid DateTime. There is an unknown word starting at index 0 http://stackoverflow.com/questions/10625292/the-string-was-not-recognized-as-a-valid-datetime-there-is-an-unknown-word-star library 8kb3ddd4.aspx DateTime currentdate int result try EXAMPLE 2012 04 15 15 23 34 123 DateTime backupdate DateTime.ParseExact..
BigInteger to Hex/Decimal/Octal/Binary strings? http://stackoverflow.com/questions/14048476/biginteger-to-hex-decimal-octal-binary-strings from other value types where leading zeros are suppressed. EXAMPLE var positiveBigInt new BigInteger 128 var negativeBigInt new..
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 else... I would really appreciat any help. EDITED AN EXAMPLE OF WHAT I HAVE Basically all mapping is working as it should..
How to delay static initialization within a property http://stackoverflow.com/questions/3065952/how-to-delay-static-initialization-within-a-property instance LogObject new BaseLogger null null null USAGE EXAMPLE Optional initialization done once when the application launches.....
Retrieving the calling method name from within a method [duplicate] http://stackoverflow.com/questions/615940/retrieving-the-calling-method-name-from-within-a-method of the method that called this popular method. Pseudo Code EXAMPLE public Main PopularMethod public ButtonClick object sender EventArgs..
C# Permutation of an array of arraylists? http://stackoverflow.com/questions/710670/c-sharp-permutation-of-an-array-of-arraylists list of all the permutations of the values in the arrays. EXAMPLE all values are strings myList 0 1 5 3 9 myList 1 2 3 myList..
|