Hey people! Hope you are having a good time developing apps and the simple calculator app I submitted yesterday was quite useful to you. And I hope that you all would have practiced it by coding on your own. If you get any error its good you’re a coder, and if you don’t get any error then you are the real code guru. Today I am going to just briefly describe a very simple statement. You did learn about the if-else statement before and we had a whale of a time doing it. Now I have a new statement which can actually do almost the same thing but in a compact manner. It’s is called the inline statement.
Suggested Reading :
- Beginner’s Guide to Windows Phone 7 App development
- Create Hello World Application in Windows Phone 7
- Different properties of Windows Phone 7 emulator
- Coding the Hello World Application in Windows Phone 7
- How files interact in Windows Phone 7 App development
- Declaring Variables in Windows Phone Application Development
- Accepting input & displaying it in Windows Phone Application Development
- Using If Else Statement in Windows Phone 7 App Development
- How to create a Calculator App for Windows Phone 7
Visuals are included.
Same pinch!
1. Before I jump into describing this statement, let’s remember what we did with the if-else statement. We had some condition/s which the computer would evaluate and if those conditions are satisfied, then the statements inside if would be executed, else if the condition/s were not satisfied, then the else part would be executed.
2. Let us take a look at the inline statement now. It kinda looks like this in syntax-
(<condition/s>) ? <statement1> :<statement2>;
Do not miss the symbols ‘?’ and ‘:’ in between. Now this statement will check the condition/s that we have assigned, and if the condition/s is/are satisfied then it will execute the part and if it does not satisfies the condition/s it will execute the part. Pretty slick, huh?
3. Let’s now do the coding part and see if this works or not. I will try to convert the same if-else statement we did last time and see if we have similar results or not.

As you can see, I have written the code such that if the user chooses the option 1 then the value ‘car’ will be assigned to the TextBlock2 and else the value ‘bike’ will be assigned to the TextBlock2. Now let’s try to run the code and see if it works-

It works for the option 1. Let’s now see if it works for the other conditions, like 2-

If you would have noticed, the statement can deal with only a single condition. If the condition is not satisfied, then the statement will execute the else part which is kinda a drawback when you want more control over the functioning of the app.
But the main thing is how it reduced the 6 or 7 line if-else statement into a 2 line code. So this is very useful in situations where you have only two situations to deal with. It can be quite handy in many occasions. And your today work is to try on your own and use many if statements, create number of sessions and check what happens to your code . if you get any problem just feel free to contact , I’m here to help you with , and help you to solve many problems.
Will be back with more next time!!




These blog is huge help in my job. Thanks that you’ve shared.
Hi Myrtle,
Thanks for your valuable comments. Hope it really helped you in your job.
Hey there! Someone in my Myspace group shared this website with us so I came to take a look. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers! Wonderful blog and amazing design.
Hi Windows 7 ,
Thanks for giving such a motivational comment. I think you be glad enough to check out all the article which are related to the Windows Phone 7 App Development.