-3

Whats the "Default" keyword in this method?

public IEnumerable<T> createEmpty(Object key)
{
    foreach (var item in MyCollection)
    {
        T element = new T(); 
        element = default(T);
        yield return element;
    }
}
Joe
  • 25
  • 2
  • 4
    Why is the title different from the question? – Blam Aug 19 '13 at 18:41
  • 1
    How about reading some c# docs? Google is smart enough, even if you type your title, it brings the answer in the first result – I4V Aug 19 '13 at 18:41
  • possible duplicate of [What does default(object); do in C#?](http://stackoverflow.com/questions/2432909/what-does-defaultobject-do-in-c). Please take some time to Google your question before asking. – tnw Aug 19 '13 at 18:42
  • @tnw thanks for editing my answer, i didn't notice that mistake – Marcel James Aug 19 '13 at 18:46

1 Answers1

3

You mean the "Default" keyword?

Question already answered here: What does default(object); do in C#?

Thats only a method that returns the default value for that type, for example:

Int32 number = default(Int32); // returns 0
Object myObject = default(Object); // returns null
bool flag = default(bool);  // return false
Community
  • 1
  • 1
Marcel James
  • 834
  • 11
  • 20