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 | 5 Comments    
Filed under: , ,
Preprocess Win32 Messages through Windows Forms
20 October 04 04:59 PM
In the unmanaged world, it was quite common to intercept Win32 messages as they were plucked off the message queue. In that rare case in which you wish to do so from a managed Windows Forms application, your first step is to build a helper class which Read More...
Postedby CSharpFAQ | 9 Comments    
Filed under:
Be Mindful of the References / 'using' / Manifest Relationship
20 October 04 04:58 PM
Given that the .NET platform encourages binary reuse of types, it is commonplace to set references to external assemblies using the Visual Studio .NET Add Reference dialog box. Many programmers (especially those of the C(++) ilk) fear that adding unnecessary Read More...
Postedby CSharpFAQ | 9 Comments    
Filed under:
Activate 'Full Screen Mode' During your Source Code Editing
20 October 04 04:50 PM
Okay, I admit this is a rather lame tip which can hardly qualify as 'insightful', however this is one of my favorite features of Visual Studio .NET (as well as previous editions of the Visual Studio product line) which many folks are (surprisingly) unaware Read More...
Postedby CSharpFAQ | 9 Comments    
Filed under:
Leverage the C# Preprocessor
20 October 04 01:20 PM
Like other languages in the C-family, C# supports a set of 'preprocessor' directives , most notably #define , #if and #endif (technically, csc.exe does not literally have a preprocessor as these symbols are resolved at the lexical analysis phase, but Read More...
Postedby CSharpFAQ | 7 Comments    
Filed under:
Avoiding Type Name-Clashes using 'using'
20 October 04 12:58 PM
You are already aware that the C# using keyword allows you to supply hints to the compiler regarding the fully qualified name of the types within a given *.cs file. However, what you may not know is that the using keyword also allows you to build aliases Read More...
Postedby CSharpFAQ | 10 Comments    
Filed under:
Build 'Consistent' .NET assemblies with FxCop
20 October 04 12:55 PM
The term 'best practices' sends chills up the spines of many people. Reason being, what is 'best' for one is 'horrible' for another. However, if you are interested in ensuring that your custom .NET assemblies are in-sync with the coding guidelines proposed Read More...
Postedby CSharpFAQ | 1 Comments    
Filed under:
Simplified Interface Implementation a la VS .NET 2003
20 October 04 11:08 AM
Another helpful feature of VS .NET 2003 has to do with the implementation of interface types. As you know, when a class or structure agrees to implement a given interface, it must implement all of the members. Assume you wish to support an interface containing Read More...
Postedby CSharpFAQ | 2 Comments    
Filed under:
Simplified Event Handling a la VS .NET 2003
20 October 04 11:07 AM
Working with events under the .NET platform requires you to be aware of a number of details. For example, if you know the name of the event you wish to handle, you must then know the name of the related delegate type. Once you know that much, you must Read More...
Postedby CSharpFAQ | 3 Comments    
Filed under:
Integrate ildasm.exe into VS .NET 2002
20 October 04 11:05 AM
VS .NET allows you to add any number of external tools to the Tools menu. One very helpful technique is to configure ildasm.exe to automatically load up the current assembly being compiled. While VS .NET 2003 sets this up automatically, VS .NET 2002 may Read More...
Postedby CSharpFAQ | 1 Comments    
Filed under:
Add Custom .NET Assemblies to the Add Reference Dialog
20 October 04 11:03 AM
As you most likely know by now, the Add References dialog of Visual Studio .NET does not list each and every assembly on your machine, does not directly map to the Global Assembly Cache and does not list your custom assemblies. Typically this limitation Read More...
Postedby CSharpFAQ | 13 Comments    
Filed under: , ,
Leverage C# Response Files at the Command Line
20 October 04 11:02 AM
Although I'd bet most of you make use of VS .NET as opposed to the raw command line complier, csc.exe can be quite useful in a number of circumstances. However, few of us enjoy typing lengthy command line flags such as: csc /r: MyAsm.dll;MyOtherAsm.dll Read More...
Postedby CSharpFAQ | 3 Comments    
Filed under:
Be Aware of wincv.exe
20 October 04 10:58 AM
When you install the .NET SDK / VS.NET, you are provided with numerous stand alone programming tools, one of which is named wincv.exe ( Windows Class Viewer ). Many developers are unaware of wincv.exe, as it is buried away under the C:\Program Files\Microsoft Read More...
Postedby CSharpFAQ | 6 Comments    
Filed under:
Utilize the Server Explorer
20 October 04 10:56 AM
Visual Studio .NET provides a very interesting view of the world named the Server Explorer (which can be activated from the View menu). While you may already be aware many of these items can be opened within VS .NET for editing (for example, opening a Read More...
Postedby CSharpFAQ | 0 Comments    
Filed under:
More Posts Next page »

This Blog

Syndication

Page view tracker