Solved

Check if int variable is empty

Posted on 2009-07-02
1
872 Views
Last Modified: 2012-05-07
Somewhat basic but still a question,

I have a function like this..
   public string function (int _month, int _year) {

I want to fill those two variables with values if they are empty.. how to? I've done something like this but i seem to understand it wrong..

        if (_year == null) _year = DateTime.Now.Year;
        if (_month == null) _month = DateTime.Now.Month;
0
Comment
Question by:dingir
1 Comment
 
LVL 9

Accepted Solution

by:
Rahul Goel earned 200 total points
ID: 24761237
if ((_year == null) || (_year == 0)) _year = DateTime.Now.Year;
if (_month == null) || (_month == 0)) _month = DateTime.Now.Month;
Thats all right!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now