¡@

Home 

c# Programming Glossary: as

How do you do a deep copy an object in .Net (C# specifically)?

http://stackoverflow.com/questions/129389/how-do-you-do-a-deep-copy-an-object-in-net-c-specifically

C# specifically I want a true deep copy. In Java this was easy but how do you do it in C# c# .net serialization share.. specifically I want a true deep copy. In Java this was easy but how do you do it in C# c# .net serialization share improve.. approaches to this but I use a generic utility method as such public static T DeepClone T T obj using var ms new MemoryStream..

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

Control accessed from a thread other than the thread it was created on I have a scenario. Windows Forms C# .NET There is.. data on different thread trying to change existing code as little as I can I used a background worker thread which will.. different thread trying to change existing code as little as I can I used a background worker thread which will be loading..

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

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

the file using OLE Automation. The .CSV file solution is easy and is the current way I am handling this but I would like.. adding that functionality in. It's very simple small and easy to use. Plus it has a DataSetHelper that lets you use DataSets.. in. It's very simple small and easy to use. Plus it has a DataSetHelper that lets you use DataSets and DataTables to..

Encrypt/Decrypt string in .NET

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

edited this answer over time to address shortcomings please see jbtule's answer for a more robust informed solution. http.. a working example derived from the RijndaelManaged Class documentation and the MCTS Training Kit . EDIT 2012 April This.. and the MCTS Training Kit . EDIT 2012 April This answer was edited to pre pend the IV per jbtule's suggestion and as illustrated..

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

is it important to override GetHashCode when Equals method is overridden Given the following class.. when Equals method is overridden Given the following class public class Foo public int FooId get set public string FooName.. method is overridden Given the following class public class Foo public int FooId get set public string FooName get set..

Dynamic LINQ OrderBy on IEnumerable<T>

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

without the dynamic LINQ library you just need the code as below. This covers most common scenarios including nested properties... to do it with LINQ to Objects. Note that the choice of Hashtable is due to favorable locking semantics using Microsoft.CSharp.RuntimeBinder.. System.Linq using System.Runtime.CompilerServices static class Program private static class AccessorCache private static..

Use of Application.DoEvents()

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

of DoEvents . There's been an enormous amount of backlash against it but nobody ever really explains why it is bad ... really explains why it is bad . The same kind of wisdom as don't mutate a struct . Erm why does the runtime and the language.. 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...

What's the difference between String and string?

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

what is the difference between String and string note the case Example string s Hello World String S Hello World Also what.. c# string share improve this question string is an alias for System.String . So technically there is no difference. It's.. is no difference. It's like int vs. System.Int32 . As far as guidelines I think it's generally recommended to use string..

How to use HTML Agility pack

http://stackoverflow.com/questions/846994/how-to-use-html-agility-pack

HTMLAgilityPack.dll in the HTMLAgilityPack Debug or Realease bin folder. Then as an example HtmlAgilityPack.HtmlDocument.. in the HTMLAgilityPack Debug or Realease bin folder. Then as an example HtmlAgilityPack.HtmlDocument htmlDoc new HtmlAgilityPack.HtmlDocument.. HtmlAgilityPack.HtmlDocument There are various options set as needed htmlDoc.OptionFixNestedTags true filePath is a path to..

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

winforms invoke share improve this question EDIT As per SilverHorse's update comment the solution you want then..

Dependency Inject (DI) “friendly” library

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

the SOLID class design principles as much as possible. As such there will probably be classes intended for consumers to.. a dependency by calling a container from within your code. Ask for it implicitly by using Constructor Injection . Use Constructor..

String vs string in C# [duplicate]

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

there is no difference. It's like int vs. System.Int32 . As far as guidelines I think it's generally recommended to use..

When to Use Static Classes in C#

http://stackoverflow.com/questions/241339/when-to-use-static-classes-in-c-sharp

services that just did their job and nothing else. As a system grows however dragons be coming. Polymorphism Say we.. a derivate class and change the method contents as needed. As it's a static method we can't. Sure if we just need to add functionality.. goes hand in hand with the interface woes mentioned above. As our ability of interchanging implementations is very limited..

How to convert UNIX timestamp to DateTime and vice versa?

http://stackoverflow.com/questions/249760/how-to-convert-unix-timestamp-to-datetime-and-vice-versa

to convert UNIX timestamp to DateTime and vice versa As the title says really. There is this example code but then it..

C# Captured Variable In Loop

http://stackoverflow.com/questions/271440/c-sharp-captured-variable-in-loop

due to all actions are referring to one captured variable. As a result when they get invoked they all have same output. Is..

How to detect Windows 64-bit platform with .NET?

http://stackoverflow.com/questions/336633/how-to-detect-windows-64-bit-platform-with-net

Framework 2.0 on 64 bit Windows it would return 32 bit . As Microsoft's Raymond Chen describes you have to first check if.. CallingConvention CallingConvention.Winapi return MarshalAs UnmanagedType.Bool private static extern bool IsWow64Process..

Case insensitive 'Contains(string)'

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

the same word in English but different words in Turkish . As I understand one means 'spirit' and the other is an onomatopoeia..

.NET String to byte Array C#

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

bytes 0 chars 0 bytes.Length return new string chars As long as your program or other programs don't try to interpret..

Casting vs using the 'as' keyword in the CLR

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

a nullable value type is actually slower but consistent. As per naasking's answer is and cast or is and as are both as fast.. object FindLengthWithIsAndCast values FindLengthWithIsAndAs values FindLengthWithAsAndNullCheck values static void FindLengthWithIsAndCast.. values FindLengthWithIsAndAs values FindLengthWithAsAndNullCheck values static void FindLengthWithIsAndCast object..

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

dividing 1 by 3 can't be exactly represented for example. As for what to use when For values which are naturally exact decimals..

What's the difference between String and string?

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

there is no difference. It's like int vs. System.Int32 . As far as guidelines I think it's generally recommended to use..

Deep cloning objects in C#

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

Code Project a while ago and incorporated it in our stuff. As mentioned elsewhere it does require your objects to be serializable...

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

or any input stream and then execute those dynamically Assuming what is provided to me would compile fine within any Main.. .NET languages is to use the CodeDOM for such things. As a note its other main purpose is for dynamically constructing.. true CompilerResults results csc.CompileAssemblyFromSource parameters @ using System.Linq class Program..

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

clauses on the query to be based on the final value of s . As explained here this happens because the s variable declared.. while enumerator.MoveNext string s s enumerator.Current As pointed out here there are no performance advantages to declaring..

C# Finalize/Dispose pattern

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

wc_DownloadStringCompleted Start the Async call to find if NoGateway is true or false public void NoGatewayStatus.. is true or false public void NoGatewayStatus Start the Async's download Do other work here wc.DownloadStringAsync new.. the Async's download Do other work here wc.DownloadStringAsync new Uri www.xxxx.xxx private void wc_DownloadStringCompleted..

How can I detect the encoding/codepage of a text file

http://stackoverflow.com/questions/90838/how-can-i-detect-the-encoding-codepage-of-a-text-file

that plain text is ASCII. There Ain't No Such Thing As Plain Text. If you have a string in memory in a file or in an..

LINQ to SQL - Left Outer Join with multiple join conditions

http://stackoverflow.com/questions/1122942/linq-to-sql-left-outer-join-with-multiple-join-conditions

LINQ SELECT f.value FROM period as p LEFT OUTER JOIN facts AS f ON p.id f.periodid AND f.otherid 17 WHERE p.companyid 100.. this SELECT f.value FROM period as p LEFT OUTER JOIN facts AS f ON p.id f.periodid WHERE p.companyid 100 AND f.otherid 17..

SQL Query slow in .NET application but instantaneous in SQL Server Management Studio

http://stackoverflow.com/questions/2736638/sql-query-slow-in-net-application-but-instantaneous-in-sql-server-management-st

the SQL SELECT tal.TrustAccountValue FROM TrustAccountLog AS tal INNER JOIN TrustAccount ta ON ta.TrustAccountID tal.TrustAccountID.. SELECT MAX tal.trustaccountlogid FROM TrustAccountLog AS tal INNER JOIN TrustAccount ta ON ta.TrustAccountID tal.TrustAccountID.. SELECT tal.TrustAccountValue FROM TrustAccountLog AS tal INNER JOIN TrustAccount ta ON ta.TrustAccountID tal.TrustAccountID..

Sharing sessions across applications using the ASP.NET Session State Service

http://stackoverflow.com/questions/2868316/sharing-sessions-across-applications-using-the-asp-net-session-state-service

sessions across applications using the ASP.NET Session State Service I am trying to share sessions between.. Stored procedure TempGetAppID tweak to @appId int OUTPUT AS start change Use the application name specified in the connection..

LINQ to SQL using GROUP BY and COUNT(DISTINCT)

http://stackoverflow.com/questions/448203/linq-to-sql-using-group-by-and-countdistinct

and non optimized at all SQL query SELECT t1 . answer_nbr AS a_id SELECT COUNT FROM SELECT CONVERT Bit t2 . user_nbr AS value.. AS a_id SELECT COUNT FROM SELECT CONVERT Bit t2 . user_nbr AS value t2 . answer_nbr t2 . poll_nbr FROM TPOLL_ANSWER AS t2.. AS value t2 . answer_nbr t2 . poll_nbr FROM TPOLL_ANSWER AS t2 AS t3 WHERE t3 . value 1 AND t1 . answer_nbr t3 . answer_nbr..

LINQ Expression to return Property value?

http://stackoverflow.com/questions/567963/linq-expression-to-return-property-value

this SQL code SELECT t0 . Id ... t0 . Version FROM Refill AS t0 WHERE t0 . Id IN @p0 @p1 @p2 @p3 @p4 ... That query 4 more..

Getting return value from stored procedure in C#

http://stackoverflow.com/questions/706361/getting-return-value-from-stored-procedure-in-c-sharp

dbo . Validate @a varchar 50 @b varchar 50 output AS SET @Password SELECT Password FROM dbo.tblUser WHERE Login @a..

Return value from SQL Server Insert command using c#

http://stackoverflow.com/questions/9319532/return-value-from-sql-server-insert-command-using-c-sharp

var cmd INSERT INTO foo column_name VALUES @Value SELECT CAST scope_identity AS int using var insertCommand new SqlCommand.. foo column_name VALUES @Value SELECT CAST scope_identity AS int using var insertCommand new SqlCommand cmd con insertCommand.Parameters.AddWithValue..