Sometimes optimization mechanism build in the compilator is able to do some strange things. For example when the following code is concerned we think than reference var1 is not equal the var2 reference.
string var1 = "text";
string var2 = "text";
bool condition = object.ReferenceEquals(var1, var2);
But the optimizer of the C# "thought" that it is not needed to create some new reference on the management heap and it uses the local one.
When we make a little change in the previous code, for example modify the second string by adding the "t" letter at the end of it after its initialization
string var1 = "text";
string var2 = "tex";
var2 += "t";
bool condition = object.ReferenceEquals(var1, var2);
then the references will not be eqal.
This could be a cause of a huge set of problems in the real programming world, so take care about it :)
A few words about me, things I'm interested in and other more or less useful things...
Sunday, March 21, 2010
Nullable values in the C# language
Nullable value = 5;
value = null;
System.Diagnostics.Debug.Assert(value == null);
or
int? value = 5;
value = null;
System.Diagnostics.Debug.Assert(value == null);
Clear and easy, doesn't it? :)
value = null;
System.Diagnostics.Debug.Assert(value == null);
or
int? value = 5;
value = null;
System.Diagnostics.Debug.Assert(value == null);
Clear and easy, doesn't it? :)
What's new in C# 4.0
Spending time on doing nothing I have found a really god article about some news in the 4-th version of C# which I would like to present in this post. Especially I have ben interested in one construction in particular which allows the programmer invoking some method for the all elements of a collection in the pararell way. It looks like the following one:
string []tab=new string[]{"a","b","c","d","e"};
System.Threading.Tasks.Parallel.ForEach(tab, Method);
where
private static void Method(string val)
{
}
string []tab=new string[]{"a","b","c","d","e"};
System.Threading.Tasks.Parallel.ForEach
where
private static void Method(string val)
{
}
Sunday, March 14, 2010
Sunday, March 7, 2010
Saturday, March 6, 2010
How to split a large mp3 file into some smaller?
Sometimes I come across the issue that I want to listen to some mp3s on my mobile phone but the file is larger than the storage size on my cell. I 'googled' and I found mp3splt application. It's really easy in use and makes your like much better than it used to be:)
For example if you want to split some file into 10 others you should simply type the following code in your shell window and voila
mp3splt -t 10.00 zaga.mp3
For example if you want to split some file into 10 others you should simply type the following code in your shell window and voila
mp3splt -t 10.00 zaga.mp3
Subscribe to:
Posts (Atom)