The Labs \ Source Viewer \ SSCLI \ System.Configuration \ StringUtil

  1. //------------------------------------------------------------------------------
  2. // <copyright file="StringUtil.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Configuration
  16. {
  17.     using System.Collections;
  18.     using System.Collections.Specialized;
  19.     using System.Configuration;
  20.     using System.Globalization;
  21.     using System.IO;
  22.     using System.Runtime.InteropServices;
  23.     using System.Security.Permissions;
  24.     using System.Security;
  25.     using System.Text;
  26.     using System.Xml;
  27.     using Microsoft.Win32;
  28.    
  29.     static internal class StringUtil
  30.     {
  31.        
  32.        
  33. /*
  34.         * Determines if two strings are equal. Treats null and String.Empty as equivalent.
  35.         */       
  36.         static internal bool EqualsNE(string s1, string s2)
  37.         {
  38.             if (s1 == null) {
  39.                 s1 = String.Empty;
  40.             }
  41.            
  42.             if (s2 == null) {
  43.                 s2 = String.Empty;
  44.             }
  45.            
  46.             return String.Equals(s1, s2, StringComparison.Ordinal);
  47.         }
  48.        
  49. /*
  50.         * Determines if two strings are equal, ignoring case.
  51.         */       
  52.         static internal bool EqualsIgnoreCase(string s1, string s2)
  53.         {
  54.             return String.Equals(s1, s2, StringComparison.OrdinalIgnoreCase);
  55.         }
  56.        
  57.        
  58. /*
  59.         * Determines if the first string starts with the second string, ignoring case.
  60.         */       
  61.         static internal bool StartsWith(string s1, string s2)
  62.         {
  63.             if (s2 == null) {
  64.                 return false;
  65.             }
  66.            
  67.             return 0 == String.Compare(s1, 0, s2, 0, s2.Length, StringComparison.Ordinal);
  68.         }
  69.        
  70. /*
  71.         * Determines if the first string starts with the second string, ignoring case.
  72.         */       
  73.         static internal bool StartsWithIgnoreCase(string s1, string s2)
  74.         {
  75.             if (s2 == null) {
  76.                 return false;
  77.             }
  78.            
  79.             return 0 == String.Compare(s1, 0, s2, 0, s2.Length, StringComparison.OrdinalIgnoreCase);
  80.         }
  81.        
  82.         static internal string[] ObjectArrayToStringArray(object[] objectArray)
  83.         {
  84.             string[] stringKeys = new string[objectArray.Length];
  85.             objectArray.CopyTo(stringKeys, 0);
  86.             return stringKeys;
  87.         }
  88.        
  89.     }
  90. }

Developer Fusion