Browse by Tags

How do I create a constant that is an array?
03 December 04 09:33 AM
Strictly speaking you can't, since const can only be applied to a field or local whose value is known at compile time. In both the lines below, the right-hand is not a constant expression (not in C#). const int [] constIntArray = newint [] {2, 3, 4}; Read More...
Postedby CSharpFAQ | 6 Comments    
How do I get and set Environment variables?
02 December 04 09:01 AM
Use the System.Environment class. Specifically the GetEnvironmentVariable and SetEnvironmentVariable methods. Admitedly, this is not a question specific to C#, but it is one I have seen enough C# programmers ask, and the ability to set environment variables Read More...
Postedby CSharpFAQ | 7 Comments    
Filed under: , ,
Is it possible to output the command-line used to build a project in Visual Studio?
30 November 04 02:54 PM
Now that Whidbey has been out in Beta for more than a few months, it seems worth revisiting some frequently asked questions which have different (better?) answers now. In Everett (v7.1) the answer used to be No. However, in Whidbey (v8.0), the answer Read More...
Postedby CSharpFAQ | 6 Comments    
Filed under: , ,
How can I subscribe to events exposed by a remoted object?
28 April 04 09:34 PM
Delegates require information about the type that the method is associated with in order to make a call. In a single app-domain, this isn't a problem, because the server (the object firing the events) has access to the type information for the client Read More...
Postedby CSharpFAQ | 3 Comments    
Filed under:
Why does my Windows Form project not use visual styles in XP even when I call Application.EnableVisualStyles?
28 April 04 09:15 PM
If you set a property on a Windows Forms control which forces the creation of the control (e.g. the SelectedIndex property on the ComboBox class), the control (and perhaps the rest of the form) will not render with visual styles enabled. The resolution Read More...
Postedby CSharpFAQ | 6 Comments    
Filed under:
How can I update my user interface from a thread that did not create it?
17 March 04 08:58 PM
When performing any action on a control which requires the updating of a user interface element (e.g. setting the Text property on almost any class derived from Control, updating the data source behind a DataGrid), these operations MUST take place on Read More...
Postedby CSharpFAQ | 19 Comments    
Filed under:
Where can I find sample C# code for simple threading?
15 March 04 04:02 PM
Refer to the System.Threading namespace on MSDN for full details. Meanwhile here is a quick taste. using System; using System.Threading; class ThreadTest { public void Runme() { Console.WriteLine( "Runme Called" ); Thread.Sleep(10000); } public static Read More...
Postedby CSharpFAQ | 11 Comments    
Filed under:

This Blog

Syndication

Page view tracker