Monday, July 24, 2006

C#.net 2.0 new features

New features of C#.Net 2.0
In the upcoming posts, we are going to discuss about new features added to .Net CLR 2.0. The features will be like:
1) TryParse
2) Nullable types
3) Generics
4) Delegates, Anonymous methods
5) Partial types
6) ?? operator
7) Global namespace qualifier
8) Property Accessor Accessibility
TryParse:
This is used to convert variable from one data type to other. In .Net 1.1 compiler, we are haivng "Parse" to do it. If the conversion not happens, it will throw exception. We can use this "TryParse" to avoid that exception.
Code snippet:
int var1;
bool result = int32.TryParse("string", out var1);
The above mentioned code example will return false to result. Hence, it wont throw any exception.
Refer the below example with valid conversion.
int var2;
bool result = int32.TryParse("52", out var2);
This is a valid conversion. Hence, the string "52" will convert to var2 variable.
Ok. We will discuss about other topics in my upcoming blogs.
See you soon....
:)

1 comment:

  1. Also check out this TryParse article and a small demo application from here.

    ReplyDelete