Sign in
MSDN Blogs
Microsoft Blog Images
More ...
MSDN Blogs
>
C# Frequently Asked Questions
>
May, 2004
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
May, 2004
Subscribe via RSS
Sort by:
Most Recent
|
Most Views
|
Most Comments
Excerpt View
|
Full Post View
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
How are return values from a delegate handled?
Posted
over 9 years ago
by
CSharpFAQ
4
Comments
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...
C# Frequently Asked Questions
Why don't nullable relational operators return bool? instead of bool?
Posted
over 9 years ago
by
CSharpFAQ
12
Comments
Q: Why don't nullable relational operators return “bool?” instead of “bool“? Nullable types are a new feature of C# 2.0 . When dealing with nullable types, if you write the following: int? i = 15; int? j = 16; the type...
C# Frequently Asked Questions
Why can't I use the same variable as an inner loop does?
Posted
over 9 years ago
by
CSharpFAQ
12
Comments
Q: Why can't I do the following: namespace Bug { class Class1 { [ STAThread ] static void Main ( string [] args ) { for ( int i = 0; i < 100; i ++ ) { } int i = 0; } } } the compiler gives me an error...
C# Frequently Asked Questions
How do I write a method that accepts a variable number of parameters?
Posted
over 9 years ago
by
CSharpFAQ
10
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) . Q: How do I write a method that accepts a variable number of parameters? ...
C# Frequently Asked Questions
Why doesn't C# support static method variables?
Posted
over 9 years ago
by
CSharpFAQ
16
Comments
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...
C# Frequently Asked Questions
Why must attribute properties be read/write in C#?
Posted
over 9 years ago
by
CSharpFAQ
5
Comments
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...
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
20
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...
Page 1 of 1 (8 items)