Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Enumerable Class
Collapse All/Expand All Collapse All
Members FilterMembers Filter
Frameworks FilterFrameworks Filter
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Enumerable..::.DefaultIfEmpty Method

Returns the elements of an IEnumerable<(Of <(T>)>), or a default valued singleton collection if the sequence is empty.

  NameDescription
Public methodStatic memberSupported by the .NET Compact FrameworkSupported by the XNA FrameworkDefaultIfEmpty<(Of <(TSource>)>)(IEnumerable<(Of <(TSource>)>))Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty.
Public methodStatic memberSupported by the .NET Compact FrameworkSupported by the XNA FrameworkDefaultIfEmpty<(Of <(TSource>)>)(IEnumerable<(Of <(TSource>)>), TSource)Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.
Top
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Default value of a reference object is null      Ben Fulton   |   Edit   |   Show History
Calling the empty DefaultIfEmpty<MyClass>() returns null. You have to pass a parameter to get the default constructor:

DefaultIfEmpty( new MyClass() )
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker