How thread can access local variable even after the method has finished?

Say I have a C# method like this: Here method creates a thread which access the local variable created in method. By the time it access this variable the method has finished and thus a local variable ...

5 May at 17:20

How to read a Stream and reset its position to zero even if stream.CanSeek == false

How do I read a Stream and reset its position to zero even if `stream.CanSeek == false`? I need some work around.

6 May at 09:53

How to access class member by string in C#?

Is there a way to access member by a string (which is the name)? E.g. if static code is: but I only have two strings: I know in JavaScript you can simply do: But how to do it in C#? Also, is it possib...

7 May at 04:33

Why Does ParameterizedThreadStart Only Allow Object Parameter?

Please let me know why `__ParameterizedThreadStart__` class only allow method which only `System.Object` argument type contain. ```csharp public class MainThreadTest { public static void Main(string...

7 May at 04:33

IQueryable C# Select

this is my code... but i need select only column to display in my Datagridview. I Need the code to select only some columns.. example

7 May at 06:35

how to write description for method

I want to have some description for my method and i want the description show in the same format that i type.. however, those text will always display in oneline. Is there any tag that i can use to as...

6 May at 04:55

Excel library documentation

I found many recommendations here to use **Excel Library** for editing Excel files, but I can't find any documentation anywhere.

7 May at 07:57

Why does unloaded event of window do not fire in WPF?

In my WPF application I have created a window and show it as a dialog by calling it by the method ShowDialog(). But when I close the window by Close() method the Unloaded event is not fired for this d...

5 May at 16:15

How to set focus back to form after opening up a process (Notepad)?

I open up a notepad from my program using `Process.Start()` but the new opened notepad covers the screen. But I do want my application to maintain its focus. I similarly (using the same Process.Start)...

How is using Entity + LINQ not just essentially hard coding my queries?

So I've been developing with Entity + LINQ for a bit now and I'm really starting to wonder about best practices. I'm used to the model of "if I need to get data, reference a stored procedure". Stored ...

2 May at 10:42

Convert Local Time Zone to PST Time Zone in C#

Let say my time zone in system right now is +5GMT right now on my machine `01/14/2012 05:52PM` I want to convert it into PST time zone like 1/14/12 4:52:50 AM PST and vice versa PST to GMT

5 May at 14:31

How can C# use a legacy DLL simply without registration(regsvr32)

### Situation I run a build system that executes many builds for many project. To avoid one build impacting another we lock down the build user to only its workspace. Builds run as a non privileged us...

Can object.GetHashCode() produce different results for the same objects (strings) on different machines?

Is it possible one and the same object, particularly a `string` or any primitive or very simple type (like a `struct`), to produce different values of the `.GetHashCode()` method when invoked on diffe...

7 May at 03:6

SharpZipLib create an archive with an in-memory string and download as an attachment

I use DotNetZip to create a zip archive with an in memory string and download it as an attachment with the following code. Now I have a requirement to do the same with SharpZipLib. How can I do it? Do...

6 May at 19:43

Keep an Application Running even if an unhandled Exception occurs

**What ?** I am developing a Console Application that needs to keep running 24/7 **No Matter What**Is there any way to stop a Multi-Threaded Application from getting blown up by some unhandled excepti...

5 May at 13:17

Drawing vertical text in WPF using DrawingContext.DrawText()

I am doing some custom drawing using DrawingContext in WPF. I am using `DrawingContext.DrawText` for drawing strings. Now, at a place I want to draw the text vertically. Is there any option in the Dra...

6 May at 04:55

How to obtain the invocation list of any event

How to get the delegate list form event of the control in WPF. I have tried the following code but it will return the field info as null

7 May at 07:58

C# using others code

Iv'e downloaded a C# interval tree collection class class from here http://intervaltree.codeplex.com/SourceControl/list/changesets -> Right hand side -> Download. However I can't open the whole projec...

6 May at 06:49

How to limit CPU usage of a process

I want to create a program which can limit cpu usage of a process even when the computer is idle. I have made a program that set priority of process, but if the computer is idle, the cpu usage can rea...

5 May at 18:13

How to send a string over a socket in C#

I am testing this locally, so the IP to connect to can be `localhost or 127.0.0.1` After sending it, it receives a string back. That would also be handy.

5 May at 16:15

Best method to "block" until certain condition is met

I would like to create some method to be used in a generic way, were it would block (unless a certain timeout expires) until a given condition is met. The usage in code would be something similar to: ...

7 May at 07:58

Linq access property by variable

Let's say I have a class like: Now, let's assume I have a `public List myList` which I want to filter by Linq as so: Everything is nice and clear until now. But how can access the property by variable...

5 May at 10:46

How can I combine multiple statement in lambda expression

I am new to this LINQ field and one thing am trying to do. I have an action delegate(written below) which i want to convert in lambda expression. What will be the lambda expression for same. I jus...

6 May at 17:53

When to use the Stack<T> collection in C#?

I do understand how `Stack()` and `Stack` works, but I really can't see any scenarios where an array, `List` or `IEnumerable` isn't a better and easier choice. Can anyone provide me a real world ex...

2 May at 07:27

Encrypt ConnectionString in entity framework

How can i protect my connection string? I want to use Entity Framework in C#, but it is important to me that other people can not see my Connection String.