¡@

Home 

c# Programming Glossary: where

Should Usings be inside or outside the namespace

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

case adding Outer.Math in File2 breaks File1 regardless of where the using goes. This implies that the compiler searches the..

What is a good pattern for using a Global Mutex in C#?

http://stackoverflow.com/questions/229565/what-is-a-good-pattern-for-using-a-global-mutex-in-c

hang forever if the mutex is not acquired Deals with cases where other processes abandon the mutex c# concurrency mutex share..

Best way to copy between two Stream instances

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

on will be run in a continuation. Note that depending on where the call to CopyToAsync is made the code that follows may or..

VS2010 does not show unhandled exception message in a WinForms Application on a 64-bit version of Windows

http://stackoverflow.com/questions/4933958/vs2010-does-not-show-unhandled-exception-message-in-a-winforms-application-on-a

rare to need it it is however popular with VB6 programmers where Load was a big deal. You only ever need Load when you are interested..

Casting vs using the 'as' keyword in the CLR

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

at the time of starting this answer have really explained where it's worth using which. Don't do this Bad code checks type twice.. a value type. There may be other cases involving generics where is is useful because you may not know whether T is a reference.. talks about performance other than the value type case where I've noted that unboxing to a nullable value type is actually..

When to use struct in C#?

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

Added to satisfy initialization of entry elements this is where the extra time is spent resizing the Entry array for int i 0..

Creating a blocking Queue<T> in .NET?

http://stackoverflow.com/questions/530211/creating-a-blocking-queuet-in-net

a blocking Queue T in .NET I have a scenario where I have multiple threads adding to a queue and multiple threads..

Proper use of the IDisposable interface

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

connections sockets window handles etc. But I've seen code where the Dispose method is implemented to free managed resources.. is to have Finalize and Dispose both call a third method where you pass a Boolean saying if you're calling it from Dispose..

Using .NET, how can you find the mime type of a file based on the file signature not the extension

http://stackoverflow.com/questions/58510/using-net-how-can-you-find-the-mime-type-of-a-file-based-on-the-file-signature

I am looking for a simple way to get a mime type where the file extension is incorrect or not given something similar..

Retrieving Property name from lambda expression

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

T this HtmlHelper html Expression Func T object action where T class var expression GetMemberInfo action string name expression.Member.Name..

Create Generic method constraining T to an Enum

http://stackoverflow.com/questions/79126/create-generic-method-constraining-t-to-an-enum

static T GetEnumFromString T string value T defaultValue where T Enum if string.IsNullOrEmpty value return defaultValue foreach.. public static T ParseEnum T string value T defaultValue where T struct IConvertible if typeof T .IsEnum throw new ArgumentException.. like this public T GetEnumFromString T string value where T struct IConvertible if typeof T .IsEnum throw new ArgumentException..

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

Main string args var q from i in Enumerable.Range 1 100 where i 2 0 select i results.Errors.Cast CompilerError .ToList..

What does the [Flags] Enum Attribute mean in C#?

http://stackoverflow.com/questions/8447/what-does-the-flags-enum-attribute-mean-in-c

property AllowedColors to Red Green and Blue which values where OR'ed by the pipe AllowedColors looks like this myProperties.AllowedColors..

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

these files sometimes contain garbage because the files where created in a different unknown codepage. Is there a way to automatically..

ExecuteReader requires an open and available Connection. The connection's current state is Connecting

http://stackoverflow.com/questions/9705637/executereader-requires-an-open-and-available-connection-the-connections-curren

open in case of Connections use close and dispose them where you need them f.e. in a method use the using statement to dispose..

Multiline String Literal in C#

http://stackoverflow.com/questions/1100260/multiline-string-literal-in-c-sharp

what I have now string query SELECT foo bar FROM table WHERE id 42 I know PHP has BLOCK BLOCK Does C# have something similar.. string literal string query @ SELECT foo bar FROM table WHERE id 42 You also do not have to escape special characters when..

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

OUTER JOIN facts AS f ON p.id f.periodid AND f.otherid 17 WHERE p.companyid 100 I have seen the typical implementation of the.. f.otherid 17 condition part of the JOIN instead of in the WHERE clause Because f may not exist for some rows and I still want.. rows to be included. If the condition is applied in the WHERE clause after the JOIN then I don't get the behaviour I want...

Soft Delete Entity Framework Code First

http://stackoverflow.com/questions/12698793/soft-delete-entity-framework-code-first

String.Format UPDATE 0 SET IsDeleted 1 WHERE ID @id tableName new SqlParameter id e.ID Marking it Unchanged.. CREATE UNIQUE INDEX 0 ON dbo.Organisations Name WHERE IsDeleted 0 IX_NaturalKey And that excludes deleted items from..

Using IQueryable with Linq

http://stackoverflow.com/questions/1578778/using-iqueryable-with-linq

here is that the SQL executed will be SELECT FROM Products WHERE Cost 25 . From your POV as a developer this looks the same...

How to get Printer Info in .NET?

http://stackoverflow.com/questions/296182/how-to-get-printer-info-in-net

string query string.Format SELECT from Win32_Printer WHERE Name LIKE ' 0 ' printerName ManagementObjectSearcher searcher..

how to do subquery in LINQ

http://stackoverflow.com/questions/418609/how-to-do-subquery-in-linq

the query I'm trying to convert to LINQ SELECT FROM Users WHERE Users.lastname LIKE ' fra ' AND Users.Id IN SELECT UserId FROM.. ' AND Users.Id IN SELECT UserId FROM CompanyRolesToUsers WHERE CompanyRoleId in 2 3 4 There is a FK relationship between CompanyRolesToUsers..

LINQ Expression to return Property value?

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

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

Parameterized Query for MySQL with C#

http://stackoverflow.com/questions/652978/parameterized-query-for-mysql-with-c-sharp

private String readCommand SELECT LEVEL FROM USERS WHERE VAL_1 AND VAL_@ public bool read string id level 1 MySqlCommand.. instead private String readCommand SELECT LEVEL FROM USERS WHERE VAL_1 @param_val_1 AND VAL_2 @param_val_2 public bool read string..

.NET - Convert Generic Collection to DataTable

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

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

Entity Framework 4.1. Most efficient way to get multiple entities by primary key?

http://stackoverflow.com/questions/8107439/entity-framework-4-1-most-efficient-way-to-get-multiple-entities-by-primary-key

var sql string.Format SELECT FROM MyDb . dbo . MyEntities WHERE ID IN 0 values var result context.Set MyEntity .SqlQuery sql..

.NET Events for Process executable start

http://stackoverflow.com/questions/848618/net-events-for-process-executable-start

TargetInstance FROM __InstanceCreationEvent WITHIN 10 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name.. TargetInstance FROM __InstanceDeletionEvent WITHIN 10 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name..

ExecuteReader requires an open and available Connection. The connection's current state is Connecting

http://stackoverflow.com/questions/9705637/executereader-requires-an-open-and-available-connection-the-connections-curren

PromotionID PromotionTitle PromotionURL FROM Promotion WHERE PromotionID @PromotionID using var da new SqlDataAdapter queryString..

Order of LINQ extension methods does not affect performance?

http://stackoverflow.com/questions/10110013/order-of-linq-extension-methods-does-not-affect-performance

methods. Tested with Enumerable.FirstOrDefault hugeList.Where x x.Text.Contains 10000 .FirstOrDefault hugeList.FirstOrDefault.. sw1.Start for int i 0 i 1000 i hugeList.Where x x.Text.Contains 10000 .FirstOrDefault sw1.Stop sw2.Start for.. 10000 sw2.Stop sw1.Restart for int i 0 i 1000 i hugeList.Where x x.Text.Contains 10000 .FirstOrDefault sw1.Stop var result2..

JavaScriptSerializer.Deserialize - how to change field names

http://stackoverflow.com/questions/1100191/javascriptserializer-deserialize-how-to-change-field-names

detail_level public DetailLevel DetailLevel get set Where DetailLevel is an enum with Low as one of the values. This test..

C# Reading a File Line By Line

http://stackoverflow.com/questions/1271225/c-sharp-reading-a-file-line-by-line

a lazily evaluated sequence without buffering perfect for Where etc. Note that if you use OrderBy or the standard GroupBy it..

Design - Where should objects be registered when using Windsor

http://stackoverflow.com/questions/1410719/design-where-should-objects-be-registered-when-using-windsor

Where should objects be registered when using Windsor I will have..

WPF global exception handler

http://stackoverflow.com/questions/1472498/wpf-global-exception-handler

any message. The application simply close instantly. Where is the best place to implement the global Try Catch block. At..

How do ValueTypes derive from Object (ReferenceType) and still be ValueTypes?

http://stackoverflow.com/questions/1682231/how-do-valuetypes-derive-from-object-referencetype-and-still-be-valuetypes

derive from classes but all ValueTypes derive from Object. Where is this distinction made How does the CLR handle this c# .net.. from System.Object. And all enums derive from System.Enum. Where is this distinction made It's made everywhere in the world that..

Fast fourier transform in c#

http://stackoverflow.com/questions/170394/fast-fourier-transform-in-c-sharp

fourier transform in c# Where can I find a free very quick and reliable implementation of..

Preserving order with LINQ

http://stackoverflow.com/questions/204505/preserving-order-with-linq

Except Intersect OfType Skip SkipWhile Take TakeWhile Where Zip new in .net 4 Destroys Order we don't know what order to..

Dependency Inject (DI) “friendly” library

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

This is called the Composition Root . More details here Where should I do dependency injection with Ninject 2 Design Where.. should I do dependency injection with Ninject 2 Design Where should objects be registered when using Windsor Simplify using..

Where to learn about VS debugger 'magic names'

http://stackoverflow.com/questions/2508828/where-to-learn-about-vs-debugger-magic-names

to learn about VS debugger 'magic names' If you've ever used..

What is the best way to store user settings for a .NET application?

http://stackoverflow.com/questions/26369/what-is-the-best-way-to-store-user-settings-for-a-net-application

application I have a .NET 2.0 Windows Forms application. Where is the best place the store user settings considering Windows..

How to get ALL child controls of a Windows Forms form of a specific type (Button/Textbox)?

http://stackoverflow.com/questions/3419159/how-to-get-all-child-controls-of-a-windows-forms-form-of-a-specific-type-button

like the following Dim Ctrls From ctrl In Me.Controls Where ctrl.GetType Is Textbox c# .net vb.net winforms share improve.. ctrl GetAll ctrl type .Concat controls .Where c c.GetType type To test it in the form load event I wanted..

Case insensitive 'Contains(string)'

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

paragraph word CompareOptions.IgnoreCase Where culture is the instance of CultureInfo describing the language..

Interprocess communication for Windows in C# (.NET 2.0)

http://stackoverflow.com/questions/50153/interprocess-communication-for-windows-in-c-sharp-net-2-0

be the best communication method for these two processes Where best is defined as more robust and less error prone not the..

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

pitfall. For example foreach var s in strings query query.Where i i.Prop s access to modified closure Due to the modified closure.. the modified closure the above code will cause all of the Where clauses on the query to be based on the final value of s . As..