May, 2004

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...

Q: How are multiple return values from a delegate handled?
In C#, it's possible to write a delegate such as:
delegate double GetResult(params double p);
If there is more than one method on this delegate, there are multiple return values.
A...

Update:
Named and optional (default) parameters are available starting from C# 4.0. For more information, see Named and Optional Arguments (C# Programming Guide) .
Q: How do I write a method that accepts a variable number of parameters?
...

Q: In C++, it's possible to write a static method variable, and have a variable that can only be accessed from inside the method. C# doesn't provide this feature. Why?
A: There are two reasons C# doesn't have this feature.
First, it is possible...

Q: Why must attribute properties be read/write in C#?
In the C# language, when you define an attribute class, you can define both constructor arguments and properties. For example: class MyAttribute: Attribute
{
string name;
int number;
public...

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...