String.IsNullOrWhiteSpace in .NET Framework 4

By Mohammad Mahdi Ramezanpour at March 03, 2010 03:13
Filed Under: .NET General

Microsoft .NET New Logo As you know, String class in .NET Framework contains lots of methods and properties that related to strings. One of the popular methods that we had in previous versions of .NET (3.5, 2.0, etc.) was String.IsNullOrEmpty that indicates whether a String variable contains a string or it’s Null (Nothing in VB). I’m using this method a lot of time in my project it becomes one of my favorite methods in .NET.

But what if you want to check if a String variable is Null or is contains White spaces! It’s something that I wanted to explain in this post.

In Visual Studio 2010, Microsoft introduced a new method in the String class. The method is String.IsNullOrWhiteSpace that Indicates whether a specified string is null reference (Nothing in Visual Basic), empty, or consists only of white-space characters.

How it works:

The following code shows you how to use String.IsNullOrWhiteSpace method:

using System;

public class Example
{
public static void Main()
{
string[] values = { null, String.Empty, "ABCDE",
new String(' ', 20), " \t ",
new String('\u2000', 10) };
foreach (string value in values)
Console.WriteLine(String.IsNullOrWhiteSpace(value));
}
}
// The example displays the following output:
// True
// True
// False
// True
// True
// True

For more information please visit: http://msdn.microsoft.com/en-us/library/system.string.isnullorwhitespace%28VS.100%29.aspx

Hope it helps.

Most of programmers CANNOT sleep on time

By Mohammad Mahdi Ramezanpour at March 02, 2010 11:37
Filed Under: Other

FUNNY! A computer addict. If you’re a programmer, I think you should agree with it. Most of programmers are used to sleep late and wake up soon because they’re busy with a machine named computer. Programmers are part of society who isn’t good sleepers and I think it’s totally because they’re in touch with computers. So the main question is why the computer is so addictive.

An anonymous user just asked a question:

Q: Why Is The Computer Or Internet So Addictive?

A: That is a very good question. Computer and Internet are the inventions of the modern age. They hold every kind of information and data you need to know. Mostly it helps you to do school projects and homeworks. People prefer it because it is fast and efficient. Nowadays no one would like to visit the library with heavy books and a lot of searching when you can just do all that with a click of a button while relaxing in your arm chair. You can play different games on computer and talk to anyone in the world at any time of the day. Personnel stuff or official, you can do all that in the computer with fast access to everything. While you use the computer the whole world is at your fingertips every kind of stuff. In one sentence people of every time and age preferred quick job with no or little hard work and especially the young generation, so why would they go to the library (even it is important for you as books are your best-friends) while you can do it all easily at your cosy homes. So dear friend these are the basic reasons for the addiction of Internet and computer at the present time!

Another answer which was so interesting is this:

Video Game Addiction A: Because growing has no space in it any more. No time when nothing is placed into the mind, so kids can just kind of dream or imagine. Even reading books, you got to fill in the spaces. Now the "writers" from everywhere--Disney, the Simpson's, etc., All offering fascinating, funny and often very original stuff, take up all the empty space. Most school programs offer very little in the arts of music for free, having decided these things are not essential--despite an astounding amount of evidence demonstrating that studying music enhances one's desire and understanding of math. And writing one's own poetry, or hikes, or anything creative, would create a greater desire to care about what you're "supposed to" read. In a conference on "Men and the Life of Desire," 1991, available on audiotape, Michael Meade, Robert Bly and James Hillman discussed the repression of desire in our society. Men are not encouraged. It makes them less controllable, and let's face it. SOMEONE wants us more controlled. We need to rehabilitate imagination. Then the computer would be less addictive, and so would TV and other media. I think it requires a connection to nature at a young age. Take 'em to the hills; let the kids make something, even badly, and feel good about it. Praise them for what they do with their minds and hearts and hands. Help addict them to their own creativity. It's not hopeless.

computer-cartoon-freak-copyright8 Like other kinds of people, programmers can’t live without computer. Most of them spend about 12 hours a day working with it and prefer to spend their time with their machines and nothing more. They’re addicted like no one else and can’t quit because they’re doing businesses with it too.

Nearly all programmers prefer to work with computer in silence. They don’t like noise!

Warning: If you have a programmer wife/husband, please DONOT become involved with them when they’re working! Because they’ll get all bent out of the shape and you can’t control the situation :D

So the best way to achieve silence is to work at night (especially with everyone in the house slept).

But, is this the way to live?

Never ever!!! After some time of working with computer at night (12 AM – 6 AM) you can’t manage your sleep time anymore and most of your friends and especially family can’t stand you. After sometime, you’ll lose your mood and sociality! The best way to be a good programmer is to go to sleep at last at 1AM and wake up at 7AM and that’s it.

Conclusion

If you want to be good man of your life, it’s better to manage your sleep time. It’s never good when you sleep when others are awake or being impatient, sleepy and more. Quit this addiction a start a new life as soon as possible. If you don’t, you’ll lose your life after some time. I know people who’re got divorced just because they were addicted to the computer. Trust me if you’re a man: “No woman can stand men who’re working at home. They want you to spent time with them instead of computer! Some of them are jealous of your relationship with you and your machine.” I’m sure about it.

Currently Reading

Quote of the day

Send Persian SMS