tagged [c#-2.0]

Capturing KeyDown events in a UserControl

Capturing KeyDown events in a UserControl I have a user control with several child controls. I need the user interface to react to keypresses, so I decided to put the handling code in a MainControl_Ke...

20 Jul at 10:25

How can I evaluate C# code dynamically?

How can I evaluate C# code dynamically? I can do an `eval("something()");` to execute the code dynamically in JavaScript. Is there a way for me to do the same thing in C#? An example of what I am tryi...

10 Apr at 19:39

Unable to call Dispose?

Unable to call Dispose? This one has confused me a little... Attempting to dispose of an XmlReader Provides the following error: > 'System.Xml.XmlReader.Dispose(bool)' is inaccessible due to its prot...

6 Mar at 11:0

List of new features in C# 2.0, 3.0 and 4.0

List of new features in C# 2.0, 3.0 and 4.0 I worked on the .NET 1.1 project for a long time, and I was stuck at C# 1.0 and now I would like to catch up with the latest and greatest. Google returned a...

23 Oct at 12:12

Are event subscribers called in order of subscription?

Are event subscribers called in order of subscription? Is it safe to assume that event subscribers are called in order of subscription? Example: Is One() always called before Two() when the event is ...

17 Dec at 18:31

How to prevent sorting of data grid view

How to prevent sorting of data grid view I am using a DataGridView on windows form. It displays just two columns. By default when the application is run, if I click on the column headers, the datagrid...

8 Jun at 11:19

Server.Transfer throws Error executing child request. How to resolve?

Server.Transfer throws Error executing child request. How to resolve? I have a `HttpModule` in C# 2.0 which handles exceptions thrown. Whenever the exception is thrown, an error page (aspx) with some ...

25 Aug at 15:37

Default value for nullable value in c# 2.0

Default value for nullable value in c# 2.0 Using C# 2.0, I can specify a default parameter value like so: Since this C# 4.0 syntax isn't available: So, is there a C# 2.0 equivalent for value types? Fo...

21 Nov at 17:5

C# ASP.NET Send Email via TLS

C# ASP.NET Send Email via TLS In order to comply with [HIPAA](http://en.wikipedia.org/wiki/Health_Insurance_Portability_and_Accountability_Act) regulations, we need to send email from an external site...

5 Feb at 14:54

Kill Process after certain time + C#

Kill Process after certain time + C# how do i kill a process after say 2 or three minutes look at the following code: ``` class Program { static void Main(string[] args) { try { //de...

22 Jun at 15:22

Using C# MethodInvoker.Invoke() for a GUI app... is this good?

Using C# MethodInvoker.Invoke() for a GUI app... is this good? Using C# 2.0 and the MethodInvoker delegate, I have a GUI application receiving some event from either the GUI thread or from a worker th...

23 Apr at 15:49

how to do masking/hiding email address in c#

how to do masking/hiding email address in c# i have an issue, i have to apply masking/hiding part of email address in c#. example i have this code but its giving exception for some emails. "Index was ...

4 Aug at 10:14

The current identity (NT Authority/Network Service) does not have write access to

The current identity (NT Authority/Network Service) does not have write access to I developed a simple web application. A label and a button. On click of Button, the label will display Hello World. Wh...

29 Jun at 11:5

Convert array of strings to List<string>

Convert array of strings to List I've seen examples of this done using `.ToList()` on array types, this seems to be available only [in .Net 3.5+](http://msdn.microsoft.com/en-us/library/bb342261.aspx)...

11 Oct at 19:47

C#, weird optimization

C#, weird optimization I'm trying to read my compiled C# code. this is my code: But! We all know that a using gets translated to this: ``` { OleDbCommand insertCommand = new OleDbCommand("...", conn...

How to change System.Windows.Forms.ToolStripButton highlight/background color when checked?

How to change System.Windows.Forms.ToolStripButton highlight/background color when checked? I have a ToolStripButton that is used as a radio button. When it is checked, a blue outline surrounds the bu...

8 Jan at 09:2

More trivia than really important: Why no new() constraint on Activator.CreateInstance<T>()?

More trivia than really important: Why no new() constraint on Activator.CreateInstance()? I think there are people who may be able to answer this, this is a question out of curiosity: The generic `Cre...

3 Mar at 23:38

How to get visible row count of DataGridView after BindingSource.Filter?

How to get visible row count of DataGridView after BindingSource.Filter? I have a table with say 1640 items. I set and most of the rows disappear, leaving, say, 400 rows. I'd like to be able to tell t...

4 Feb at 00:16

Why shouldn't I always use nullable types in C#

Why shouldn't I always use nullable types in C# I've been searching for some good guidance on this since the concept was introduced in .net 2.0. Why would I ever want to use non-nullable data types in...

7 Apr at 10:11

Unable to cast COM object - Microsoft outlook & C#

Unable to cast COM object - Microsoft outlook & C# I have written this code to view the unread items in my outlook mail box and here is the code: ``` Microsoft.Office.Interop.Outlook.Application app; ...

What 'quota' is being referred to in this exception message: Not enough quota is available to process this command

What 'quota' is being referred to in this exception message: Not enough quota is available to process this command I have a .NET application that throws the following exception: ``` System.ComponentMo...

17 Feb at 18:6

GetHashCode() with string keys

GetHashCode() with string keys Hey all, I've been reading up on the best way to implement the GetHashCode() override for objects in .NET, and most answers I run across involve somehow munging numbers ...

23 Jul at 17:31

C# variable length args, which is better and why: __arglist, params array or Dictionary<T,K>?

C# variable length args, which is better and why: __arglist, params array or Dictionary? I recently read the following overflow post: [Hidden Features of C#](https://stackoverflow.com/questions/9033/h...

23 May at 12:29

Convert from IList<T> to non-generic IList

Convert from IList to non-generic IList I am implementing `IListSource` that requires a method `GetList()` with the following signature: I am using .NET framework 2 and I'm wanting to return an object...

8 Jan at 07:11

Multi-threading & db record locks

Multi-threading & db record locks Need help big time .... I need to create a .net application that will perform some bulk operations on , say around 2,000,000 records, in a table. There is a window of...

8 Aug at 22:44