jordan.terrell
Just trying to make sense of things...

Request to add operator to the C# language

Friday, 14 September 2007 11:01 by jordan.terrell

I just submitted a suggestion to add an operator to C#.  I kept the sample on the suggestion simple, but I'm really trying to enable a scenario like this:

   1:  public class SomeClass
   2:  {
   3:      private List<string> _Strings = null;
   4:   
   5:      public List<string> Strings
   6:      {
   7:          get { return _Strings ?= new List<string>(); }
   8:      }
   9:  }

 

In this sample if _Strings was null, it would create a new list of strings, assign it to the _Strings variable, and return the newly created list from the getter.  However, if _Strings was not null, the getter would simple return the list referenced by the _Strings variable.

If you like this idea, go ahead and vote on it!

Tags:  
Categories:   .NET | Programming
Actions:   E-mail | del.icio.us | Permalink | Comments (2) | Comment RSSRSS comment feed

Comments (2) -

September 14. 2007 11:04

Makes sense to me.....

Makes perfect sense to me....

Makes sense to me.....

September 14. 2007 11:06

Jonny

I'd use it.  Great thinking.

Jonny

Comments are closed