CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Coalesce

230 Views
Copy Code Show/Hide Line Numbers
   1:  /// <summary>
   2:      /// ImplementaƧƠo do mesmo coalesce do SQL
   3:      /// </summary>
   4:      /// <param name="txt"></param>
   5:      /// <param name="args">passe um numero infinito de string separadas por virgula</param>
   6:      /// <returns></returns>
   7:      public static string Coalesce(this string txt, params string[] args)
   8:      {
   9:          
  10:          string value = string.Empty;
  11:          if (!txt.IsNullOrEmpty()) return txt;
  12:          foreach (string arg in args)
  13:          {
  14:              if (!arg.IsNullOrEmpty())
  15:              {
  16:                  value = arg;
  17:                  break;
  18:              }
  19:          }
  20:          return value;
  21:      }
by Giuliano Lemes
  July 28, 2009 @ 6:39am
Tags:
Description:
Mimics sql Coalesce

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate