.NET: Redundant ToString() method
It is only when I used
Resharper that I learned I have been redundantly
calling ToString() method when concatenating other types with a string type and
assign it into string variable. The code below work just fine despite different
types involved in the expression.
1 int value1 = 100;
2 decimal value2 = 200.00M;
3 float value3 = 300;
4 object value4 = new object();
5 string querystring = Request.QueryString["key"];
6
7 //ok
8 string result1 = querystring + value4 + value3 + value2 + value1;
9 //ok
10 string result2 = value3 + querystring + value2 + value1 + value4;
11 //ok
12 string result3 = value1 + value1 + value1 + "";
HTH
Share this post: Email it! |
bookmark it! |
digg it! |
reddit!|
kick it!