Sign in
MSDN Blogs
Microsoft Blog Images
More ...
MSDN Blogs
>
C# Frequently Asked Questions
Server & Tools Blogs
>
Developer Tools Blogs
>
C# Frequently Asked Questions
Executive Bloggers
S. Somasegar
Brian Harry
Scott Guthrie
Jason Zander
Visual Studio
Visual Studio
Blend
LightSwitch
Line of Business Apps by Beth Massi
Setup & Install by Heath Stewart
Application Lifecycle Management
Visual Studio ALM
Team Foundation Service
Languages
Visual Basic
Visual C#
Visual C++
Visual F#
JavaScript
.NET Framework
.NET Framework
.NET Parallel Programming
ADO.NET (Managed Providers, DataSet & EF)
ASP.NET by Scott Hanselman
Base Class Library (BCL)
Silverlight
WCF Data Services
Workflow
Platform Development
Internet Explorer
Apps for Office and SharePoint 2013
SharePoint
Office
Web
Windows 8
Windows Store
Windows Azure
Windows Phone
C# Frequently Asked Questions
The C# team posts answers to common questions and describes new language features
Subscribe
Comments
Contact
Menu
Blog Home
Atom
Translate this page
Powered by
Microsoft® Translator
Live Now on Developer Tools Blogs
Tags
.NET Framework
.NET Framework 4
async
asynchronous programming
await
C#
C# 3.0
C# 4.0
C# compiler
C#/VB.NET Equivalents
DLR
dynamic language runtime
expression trees
IDE
parallel-processing
parallel-programming
reflection
roslyn
Task Parallel Library
Tips
TPL
Visual Studio
Visual Studio 2010
Visual Studio Async CTP
WPF
More
▼
Less
▲
Related resources
Visual Studio Developer Center
Visual Studio Product Website
Archives
Archives
September 2012
(1)
June 2012
(2)
April 2012
(1)
February 2012
(3)
January 2012
(2)
December 2011
(1)
November 2011
(3)
October 2011
(1)
August 2011
(2)
April 2011
(1)
March 2011
(1)
February 2011
(1)
November 2010
(1)
October 2010
(1)
September 2010
(1)
August 2010
(1)
July 2010
(2)
June 2010
(2)
May 2010
(1)
April 2010
(2)
March 2010
(1)
February 2010
(1)
January 2010
(2)
November 2009
(1)
October 2009
(2)
September 2009
(1)
March 2009
(1)
January 2009
(1)
October 2006
(2)
March 2006
(3)
February 2005
(1)
December 2004
(4)
November 2004
(1)
October 2004
(15)
August 2004
(3)
July 2004
(3)
June 2004
(1)
May 2004
(8)
April 2004
(4)
March 2004
(36)
More
▼
Less
▲
Blog - Title
Subscribe via RSS
Sort by:
Most Recent
|
Most Views
|
Most Comments
Excerpt View
|
Full Post View
C# Frequently Asked Questions
How can I run another application or batch file from my Visual C# .NET code?
Posted
over 9 years ago
by
CSharpFAQ
32
Comments
Posted by: Duncan Mackenzie , MSDN This post applies to Visual C# .NET 2002/2003 Suppose you want to run a command line application, open up another Windows program, or even bring up the default web browser or email program... how can you do this from...
C# Frequently Asked Questions
Why do I get the error "Object reference not set to an instance of an object"?
Posted
over 9 years ago
by
CSharpFAQ
19
Comments
The code is trying to access a member of a reference type variable that is set to null . Given the following class, let's examine some code that could be in the Main method: using System; class Foo { static void Main() { // foo has not been...
C# Frequently Asked Questions
What character escape sequences are available?
Posted
over 9 years ago
by
CSharpFAQ
20
Comments
C# defines the following character escape sequences: \' - single quote, needed for character literals \" - double quote, needed for string literals \\ - backslash \0 - Unicode character 0 \a - Alert (character 7) \b - Backspace...
C# Frequently Asked Questions
Covariance and Contravariance FAQ
Posted
over 3 years ago
by
Alexandra Rusina
32
Comments
In this post I’ll try to answer the most common questions I find on forums and in documentation feedback about C# covariance and contravariance. It’s a big topic for a single blog post, so expect to see a lot of “more information” links. Special thanks...
C# Frequently Asked Questions
How do I cast a string to an int, float, double, etc?
Posted
over 9 years ago
by
CSharpFAQ
16
Comments
You can use the Convert class or the Parse method of the built-in type you are casting to. i.e. string myStr = "123"; int myParsedInt = Int32.Parse(myStr); int myConvertedInt = Convert.ToInt32(myStr); This example uses the int type, but you can also...
C# Frequently Asked Questions
Get Ready For C# 4.0!
Posted
over 3 years ago
by
Alexandra Rusina
69
Comments
Visual Studio 2010 is here! And of course this means that C# 4.0 is also here. Let’s do a quick review of the new language features added in this release. Dynamic The dynamic keyword is a key feature of this release. It closes the gap between dynamic...
C# Frequently Asked Questions
How can I update my user interface from a thread that did not create it?
Posted
over 9 years ago
by
CSharpFAQ
33
Comments
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...
C# Frequently Asked Questions
Does C# have default parameters?
Posted
over 9 years ago
by
CSharpFAQ
36
Comments
Update: Named and optional (default) parameters are available starting from C# 4.0. For more information, see Named and Optional Arguments (C# Programming Guide) . In languages such as C++, a default value can be included as part of the method...
C# Frequently Asked Questions
Why did I receive the error: "The type or namespace '<namespace name>' does not exist in the class or namespace '<parent namespace>' (are you missing an assembly reference?)"
Posted
over 9 years ago
by
CSharpFAQ
35
Comments
You need to add a reference in your project to an assembly where that namespace is defined. If you are using VS.NET: 1. Right click on the References folder on your project. 2. Select Add Reference. 3. Select the .NET tab (or select the Browse button...
C# Frequently Asked Questions
New IDE Features in Visual Studio 2010 for C# Developers
Posted
over 3 years ago
by
Alexandra Rusina
26
Comments
After a quick review of C# language features , let’s do the same for the IDE improvements. So, what’s in there for C# developers? Generate From Usage This feature greatly improves Visual Studio support for test-driven development (TDD) . However...
C# Frequently Asked Questions
Dynamic in C# 4.0: Introducing the ExpandoObject
Posted
over 4 years ago
by
Alexandra Rusina
71
Comments
You have probably already heard about the new dynamic feature in C# 4.0 and how it is used to support COM interop. If you haven't, I strongly recommend reading the following MSDN articles: Using Type dynamic and How to: Access Office Interop Objects by...
C# Frequently Asked Questions
Introducing the Microsoft “Roslyn” CTP
Posted
over 2 years ago
by
CSharpFAQ
5
Comments
By Kevin Pilch-Bisson As Soma mentioned earlier, today we’ve made a Community Technology Preview (CTP) available for download ! The Roslyn project is a forward looking effort to make the wealth of language understanding that the compiler generates...
C# Frequently Asked Questions
How to programmatically launch Debugger in a remote machine
Posted
over 2 years ago
by
CSharpFAQ
2
Comments
This blog post explains how to kick off a debugger in a remote machine, programmatically. We are going to use WMI interfaces to achieve this. Use WMI, to start the debuggee process and attach a registered debugger to it using WMI. I have given a sample...
C# Frequently Asked Questions
What is the difference between const and static readonly?
Posted
over 9 years ago
by
CSharpFAQ
10
Comments
The difference is that the value of a static readonly field is set at run time, and can thus be modified by the containing class, w hereas the value of a const field is set to a compile time constant. In the static readonly case, the containing class...
C# Frequently Asked Questions
Parallel Programming in .NET Framework 4: Getting Started
Posted
over 3 years ago
by
Alexandra Rusina
82
Comments
With this post I want to start a series devoted to the new parallel programming features in .NET Framework 4 and introduce you the Task Parallel Library (TPL) . Update. The list of posts in this series: Getting Started (this post) Task Schedulers and...
C# Frequently Asked Questions
How do I calculate a MD5 hash from a string?
Posted
over 7 years ago
by
CSharpFAQ
14
Comments
It is a common practice to store passwords in databases using a hash. MD5 (defined in RFC 1321 ) is a common hash algorithm, and using it from C# is easy. Here’s an implementation of a method that converts a string to an MD5 hash, which is a 32-character...
C# Frequently Asked Questions
What are the advantages of C# over VB.NET and vice versa?
Posted
over 9 years ago
by
CSharpFAQ
41
Comments
The choice between C# and VB.NET is largely one of subjective preference. Some people like C#'s terse syntax, others like VB.NET's natural language, case-insensitive approach. Both have access to the same framework libraries. Both will perform...
C# Frequently Asked Questions
How do I create a constant that is an array?
Posted
over 9 years ago
by
CSharpFAQ
8
Comments
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...
C# Frequently Asked Questions
What is the difference between “dynamic” and “object” keywords?
Posted
over 3 years ago
by
Alexandra Rusina
127
Comments
Let’s take a quick look at the object keyword first. I’m not going to talk a lot about it because it’s been around since C# 1.0. This keyword is nothing more than a shortcut for System.Object , which is the root type in the C# class hierarchy. (However...
C# Frequently Asked Questions
When should I use == and when should I use Equals?
Posted
over 9 years ago
by
CSharpFAQ
21
Comments
The Equals method is just a virtual one defined in System.Object , and overridden by whichever classes choose to do so. The == operator is an operator which can be overloaded by classes, but which usually has identity behaviour. For reference...
C# Frequently Asked Questions
How do I get and set Environment variables?
Posted
over 9 years ago
by
CSharpFAQ
6
Comments
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...
C# Frequently Asked Questions
How can I easily log a message to a file for debugging purposes?
Posted
over 7 years ago
by
CSharpFAQ
12
Comments
Often, you need a way to monitor your applications once they are running on the server or even at the customer site -- away from your Visual Studio debugger. In those situations, it is often helpful to have a simple routine that you can use to log messages...
C# Frequently Asked Questions
Generating Dynamic Methods with Expression Trees in Visual Studio 2010
Posted
over 4 years ago
by
Alexandra Rusina
21
Comments
Expression trees first appeared in Visual Studio 2008, where they were mainly used by LINQ providers. You can use expression trees to represent code in a tree-like format, where each node is an expression. You can also convert expression trees into compiled...
C# Frequently Asked Questions
Why doesn't C# support multiple inheritance?
Posted
over 9 years ago
by
CSharpFAQ
24
Comments
This answer is from Chris Brumme via the following post . I've copied the text in here in case the post disappears. *** There are a number of reasons we don't implement Multiple Implementation Inheritance directly. (As you know, we support Multiple...
C# Frequently Asked Questions
Blocking Collection and the Producer-Consumer Problem
Posted
over 3 years ago
by
Alexandra Rusina
11
Comments
This time I want to discuss features that belong to the new System.Collections.Concurrent namespace in the.NET Framework 4. When you design parallel applications, you often need thread-safe data storage as well as some mechanism of sending messages between...
Page 1 of 5 (121 items)
1
2
3
4
5