« Previous entry | Next entry » Browse > Snippets

Skip to comments (19) [C#] one ? or two?
Posted by Matthijs on Jul 11 2006 @ 01:29  :: 5443 unique visits

It's quite common you have something like this in your code:

CODE: CSHARP
if (foo != null)
  bar = foo;
else
  bar = new Foobar();

// Or with less code:

bar = (foo != null) ? foo : new Foobar();


There is a nice little trick for this:

CODE: CSHARP
bar = foo ?? new Foobar();


This statement is equivalent to the two upper examples. Pretty neat huh? :)

19 comments posted so far
Add your own »

1. On Sep 11 2007 @ 21:28 guest wrote:

bar = foo ?? new Foobar();

Just a reminder:
The variable, foo, can only be a reference type.  It won't work in value type such as int.

2. On Sep 24 2007 @ 16:49 guest wrote:

Does this work for C++/CLI as well?

3. On Apr 13 2009 @ 14:56 Steve wrote:

Yeah i see it but i want to know can we use it in C++ or not if we can then i would love to use it after my 70-290 managing and maintaining a Microsoft windows server 2003 environment exam about which i am confident to pas in first attempt as i have already pass my 70-640 windows server 2008 active directory exam with high score along with the 70-649 Upgrading MCSE on wndws serv 2003 to wndws serv 2008 exam in first attempt as i will be free from all this i must see if i can use it for my work.

4. On May 09 2009 @ 18:57 maryzheng wrote:

PVC door profiles 80mm sliding PVC door profile and Leading Manufacturer/Exporter of PVC profiles, Plastic profile, PVC window, PVC sections, plastic sections, PVC pipe fittings.Other Door & PVC window accessories catalog.
The Emergency Alert EAS System is a national warning system in the U.S.- EAS System, Sport socks, cheap sport socks, what ever sport socks you want, just contact us.
We can provide Needle loom, Needle loom provider
ugg boots, world wild ugg boots cheap ugg boots, ugg boot, cheap ugg boot, ugg cardy, ugg cardy for uk, cheap ugg cardy boots are popular,we sell real ugg boots, cheap ugg boots, ugg cardy, cheap ugg cardy boots,ugg boots uk at great prices to people, we are proud to offer you the high quality and low price ugg classic cardy,ugg classic cardy shop, cardy ugg boots, cheap cardy ugg boots, ugg classic cardy boots, ugg classic cardy boots online, and ugg classic tall, ugg classic tall boot, ugg boots uk, cardy ugg boots are using 100% natural sheepskin

come on my friends . we are very glad to suplly you some handbags to you . as replica pursesreplica handbagschanel replicaChanel 2.55 bagHermes birkinHermes kellyHermes replicaHermes handbagGucci replicaGucci handbagBALENCIAGAwholesale replica handbagsLouis vuitton replicaspeedy 30Gucci IndyGucci Messenger bagGucci BabouskaGucci PrincyGucci PositanoGucci Leather bagJimmy Choo handbagPrada handbagChloe handbagMiu Miu handbagMulberry handbagsTHOMAS WYLDE handbagFendi handbagLouis Vuitton Replica speedy 30Monogram CanvasSuhali LeatherDamier CanvasMonogram MulticoloreMonogram WatercolorDamier GraphiteDamier AzurDamier GeantMonogram JokesMonogram DenimMonogram VernisMonogram MirageMonogram Mini LinMini Lin CroisetteMonogram MiroirNomade LeatherEmbossed LeatherGucci WalletsMiu Miu WalletsLouis Vuitton BeltsGucci Belts

5. On May 11 2009 @ 11:45 guest wrote:

QIXINYAN


Way to teach a dog infected with love and enjoyment of the people around them is dog training. Not all the people who keep the dog know how to train a puppy, but who often find it impossible to carry out dog obedience training , people who have a different feel that they do so. Although some people will tend to the field of veterinary medicine, other people will choose more specific career dog. Perhaps the most popular dog-centric professional area is that dog training.
Police dog training is a great way for those who love the dogs, to help them use and dissemination of information. One important thing to remember is that the dog trainer can not only teach dog tricks and working dogs and their masters. In fact, owners tend to play a bigger roll than the dogs training process.
Some people choose to learn some dog training tips from an experienced coach or a veterinary surgeon of similar projects in the apprenticeship. This is often useful, because many of these puppies training experience in the field and constant practice. Customers will often choose a coach approved no more than one certification. Other routes may be the next dog learning how to train a puppy through the animal science program behavior.

Do you know how to lose weight? No matter how you do, do not skip breakfast. People who began the day a good healthy breakfast does not have loss weight diet throughout the day than those who do not eat breakfast. Or, if you prefer to drink your breakfast to reach weight loss, fruit juice is a good choice. All you need to do is the integration and go! Super simple!
In addition, how to lose pounds? Plan your meals so you eat every 3-4 hours, about 5-6 times a day. Do you want to ensure that your last meal is 3-4 hours, and then go to bed. It seems to eat more frequently in the first strange, but studies ways to lose weight by the books and internet, you’ll not only lose pounds success, but also have the energy level of the day.

Are you annoying with belly fat? I am sure you hear that sit-ups are one of the best belly fat exercises. How to lose belly fat? There are not only belly fat exercises, but have belly fat diet. Although it is entirely correct sit-ups will strengthen the abdominal muscles and make you more powerful in this regard, you may get rid of belly fat because you’re fat to improve the muscle to hold better, which in fact did not lose belly fat itself.
The key to lose belly fat is actually quite simple. Therefore, these two key points, first of all to take action to belly fat exercises, second, have belly fat diet every day. Do these, you will lose belly fat!

As a child, you can find kids jobs to get money. If not, maybe you are considering how to make children work in additional funds. jobs for 15 year olds are so many. However, we know that you will not find a real job; you just need a working pocket money. Finding jobs for 16 year olds is not a difficult task.

To make money online, first you need to make necessary preparations. In any field or industry you need in all walks of life through appropriate channels to meet their own, in order to succeed. Can you imagine how to starting your own business? It would be a good way to Make Money on the Internet and move forward at full speed is going to just be disastrous.
In the network marketing, you can set up shop online, start flower shop, or you can start carpet cleaning business.In my opinion, there are also other popular ways to make money,for instance, So starting a laundromat business at home, another way is to manage furniture making business at home.

6. On May 13 2009 @ 15:53 guest wrote:

Need Furniture? And need to buy furniture from China at competitive price? LongYear Furniture is your source for quality bedroom furniture featuring a huge selection of home furniture a happy home for beautiful life, kids furniture for a good memory of childhood, and to gain an extra good price from wholesale furniture and direct from  furniture manufacturers China, styles of China furniture are available, living room furniture is also nice for your house, find dining room furniture and more!

9. On Jul 14 2009 @ 03:58 guest wrote:

buy wow gold
my wow power leveling
buy wow gold
good wow power leveling
BUY wow gold
my wow power leveling
CHEAP rs gold
cheap wow power leveling
CHEAPEST lotro gold
MY aion gold
buy wow gold
cheap wow gold
CHEAPEST wow gold

11. On Jan 05 2010 @ 14:45 uggbaileybutton wrote:

bailey button uggs

-ugg boots cheap

ugg boots uk

ugg classic

12. On Jan 10 2010 @ 09:35 ugg14785 wrote:

Everywhere you go now you find that the ugg boot has become the latest fashion new arrival cheap trend. now days it seems that you can not walk pass any window display of any shoe or fashion clothing store with seeing a pair of these trendy boots in them. it does not matter where ever you are in the world you will find ugg boots. these boots are both hot and trendy and certainly do not need to be worn in cold weather only. many people have found, that one pair of ugg boots is not enough.

We have been seller of UGG Boots for many years.Our customers are satisfied with our products as we offer the real UGG Australia Boots:
*100% authentic sheepskin for unrivalled comfort
*soft genuine sheepskin heel padding
*cushioning insole,flexible fabric-trimmed midsole.
*Lightweight molded EVA traction outsole
*Free shipping
*One week to your door
*If you dont like what youve received, simply return it!
welcome to  www.fineugg.com

13. On Jan 10 2010 @ 09:36 ugg14785 wrote:

Sheepskin and ugg boots are a casual type of boot. Ugg boots are exceptionally warm and are great for cold weather (up to -30 degrees Fahrenheit)If you are looking for warmth while trudging around the house or the city, a sheepskin or ugg boot will be ideal.For girls and women, ugg boots look fantastic with tight-legged jeans tucked into them, or with short skirts paired with opaque tights or bare legs. For guys, ugg boots work great with jeans, and give a very casual, or rugged look, depending on the jeans or the shirt you wear with your ugg boots.

Do you have a pair of UGG Boots?If not,you must will buy a piar in our website.As we offer the best sevice and favourable price.what's more,we charge the shipping fee.So,you just need to pay the fee of boots,and will receive our UGG boots in one week.It is very easy to have your own UGG Boots.Come on!

Our UGG Boots are all with top quality:
*features genuine twin-face sheepskin
*our signature UGG woven label
*feature a soft foam insole covered with genuine sheepskin
*have a molded EVA light and flexible outsole designed for refreshing comfort with every step
welcome to www.findugg.com

14. On Jan 10 2010 @ 09:37 ugg14785 wrote:

what's the main point of the boots?the answer is to keep your feet warm.If you by one pair of boots put them on,especially in winter,you'll feel very tenderness and comfortable.they can make your feet warm.and youll find its really fashionable.you can tie-in each kind of clothes with them and still looks beautifull.

The ugg boots will definitely make you noticeable in a fashion-conscious crowd,and more importantly,is the fact that these boots are indeed quite comfortable to wear. these boots have been popular with swimmers and surfers since the 1970s and are regularly worn by surfers in california.the design of the boot with its sheepskin results in considerable thermostatic benefits.


We sell real UGG Australia Boots in our website.You must be satisfied with our UGG Boots when you receive your order.The UGG Boots you get will have these advatages:
*100% authentic sheepskin for unrivalled comfort
*a durable molded rubber outsole.
*The wrap around lace feature adds a fashionable touch with wooden beads at the end
*A removable and replaceable sheepskin insole gives extra comfort and warmth.
*Insole is made of sheepskin,latex.
welcome to  www.famousuggs.com

15. On Jan 10 2010 @ 09:38 ugg14785 wrote:

Legend has it that "ugg" is short for "ugly" - so, "ugg boots" apparently meant "ugly boots." For decades, "ugg" was generic term used for sheepskin boots made in Australia.The word was so commonplace that it was found in Australian dictionaries, and ugg boots were also known as "ug" or "ugh" boots. But in the United States, when people refer to "UGG boots," they're usually talking about the boots made by Deckers Outdoor Corporation, the parent company of "UGG Australia."So if you're traveling the world and talking about footwear, it's good to know that when the term "ugg boot" is used, it could be referring to an Australian-made sheepskin boot, or a popular brand name boot.

We sell authentic UGG Boots in our website for many year.We offer the best service and favourable price.People all aound the world buy our products do not pay for the shipping,we charge it!

Our UGG Boots have the advantages below:
* 100% authentic sheepskin for unrivalled comfort
* genuine twin-face sheepskin for refreshing comfort
* have a molded EVA light and flexible outsole designed for amazing comfort with every step.
*You can wear them up or style them folded down

Welcome to buy UGG Boots in our website,we offer the UGG Australia boots are all with top quality!
welcome to www.e-uggs.com

16. On Jan 10 2010 @ 09:39 ugg14785 wrote:

When heard of winter, cold may come in your mind at once.if you are ready for the coming of winter,you should never be afraid of it.it is not difficult for us that if you protect your feet well,you will fell warm and comfortable.so you should get several shoes help you spend the cold winter.UGG Boots can be done.for many individuals,ugg boots provide the perfect insulation and comfort for the winter months.ugg boots are both warm and comfortable.these two factors are extremely important,no matter what amount of time you are going to be spending out in the weather.ugg boots are made out of a material that is water resistant, meaning that no water,and no cold air,can get into your boots.they will keep in the warmth of your feet,because of their outer shell and their inner linings. once you slip your feet into a pair of these boots,they will be warm and toasty until it is time to take them off.you will be able to take advantage of the great warmth that ugg boots offer.

Welcome to buy UGG Boots in our website,we offer the UGG Australia boots are with top quality:
*features genuine twin-face sheepskin for refreshing comfort
*feature a soft foam insole covered with genuine sheepskin
*have a molded EVA light and flexible outsole designed for amazing comfort with every step.
*you can enjoy free shipping worldwide in our website.
*1 week delivery to your door
*sometimes you can get a special discount from our company by email


Our customers are always satisfied with such kind of UGG Boots and our high service!

welcome to www.dressugg.com

17. On Jan 10 2010 @ 09:39 ugg14785 wrote:

The original ugg boots is not a brand name but an age old sheepskin boots generic term for this style of australian-made sheepskin boot. in Aussie slang, the ug name is short for “ugly.” in terms of comfort, however, the ug boot is a thing of beauty.Ugg boots are a popular brand of boot for women,and children.just as the chairman of australian ugg said, australian ugg is a good choice. once wearing it, you will be reluctant to take it off and be fascinated by its originality, reliability and extremely luxurious comfort. this is the art brought by boots. ugg boots make young beautiful girls and handsome boys very confident.

Our website have many fashion styels of UGG Boots for women and children.

We provide many advantages as below:
*free shipping
*hidden costs
*professional customers service
*secure processing,plus
*we dont hassle you on returns.if you dont like what youve received, simply return it!

UGG Boots must be you best choice!
welcome to www.bootshotsale.com

18. On Jan 10 2010 @ 09:40 ugg14785 wrote:

We have been exporter of UGG Australia Boots for many years,our product are all authentic.Welcome to buy any boots of them in our website,we charge the shipping fee.
We just take 7 days to deliver the products to your door.

As everyone knows,UGG Australia Boots in australia, and many other countries as well, ugg boots also ug or uggs are a style of footwear that has been used generically for well over a hundred years.Everywhere you go now you find that the ugg boot has become the latest fashion trend.

Our UGG Australia Boots are all with top quality:

*100% authentic sheepskin for unrivalled comfort
*flexible molded EVA outsole
*Insole features a genuine sheepskin sockliner that naturally wicks away moisture and keeps feet dry
*Wool blend knit uppers with suede heel guards
*Approximate Shaft Height (Uncuffed): 14.5"
*By UGG Australia;Imported.

  welcome to www.bootsdept.com

19. On Jan 10 2010 @ 09:40 ugg14785 wrote:

Ugg Boots,also called Ug or Ugg boots,are nowadays one of the most popular boots.They existed already in 1930's and became popular in 1960's when Australian surfers found out,that they can warm their feet after coming out from cold water.They have everything you need-comfort and warmth.You will never be cold in those boots because 100% sheepskin will warm you even in the coldest days.The natural thermal properties of sheepskin make possible that Ugg Boots will warm you in the winter but in the summer your feet will not be wet.It is true that Ugg is shorter from ugly,but if you know even little bit about fashion you will know that Ugg boots are not ugly.We can see famous people like Pamela Anderson or Kate Hudson wearing Ugg Boots.

Nowadays we have new improved Ugg boots for sale.You can get them for anybody.We have women boots,children boots,slippers and casuals.

Our UGG Australia Boots are all authentic.Their properties and features as below:

*In cold temperatures,the fleece works as an insulating layer of warmth and keeps the warmth of body heat inside of the boot.
*In the heat,the wool fibers keep the air circulating; thus keeping your fee dry and pulling the perspiration away from your skin.Sheepskin also contains lanolin,which moisturizes your feet when worn barefoot.
*ugg boots have reinforced toes,which are double stitched and extra durable heels.
*feature a natural,thick fleece on a removable in-sole for arch support.
*The sole is usually durable in most terrain,lightweight and provides traction as well.
welcome to www.bootscardy.com

Add a new comment

Name:
Password: (leave empty for anonymous comment)
 
View formatting tags Comment: