StringHelper.cs

  1. // ==++==
  2. // 
  3. //   
  4. //    Copyright (c) 2002 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. // 
  14. // ==--==
  15. //============================================================
  16. //
  17. // File:    StringHelper.cs
  18. //
  19. // Summary: Helper methods for strings.
  20. //
  21. //===========================================================
  22. using System;
  23. using System.IO;
  24. using System.Runtime.Remoting;
  25. namespace System.Runtime.Remoting.Channels
  26. {
  27.     internal class StringHelper
  28.     {   
  29.         internal static bool StartsWithDoubleUnderscore(String str)
  30.         {
  31.             if (str.Length < 2)
  32.                 return false;
  33.             return (str[0] == '_') && (str[1] == '_');
  34.         } // StartsWithDoubleUnderscore
  35.         internal static bool StartsWithAsciiIgnoreCasePrefixLower(String str, String asciiPrefix)
  36.         {
  37.             // The caller should know that the arguments aren't null.
  38.             int prefixLen = asciiPrefix.Length;
  39.             if (str.Length < prefixLen)
  40.                 return false;
  41.                 
  42.             for (int i = 0; i < prefixLen; i++)
  43.             {
  44.                 // The prefix is assumed to be in lowercase
  45.                 if (ToLowerAscii(str[i]) != asciiPrefix[i])
  46.                 {
  47.                     return false;
  48.                 }
  49.             }
  50.             return true;
  51.         } // StartsWithAsciiIgnoreCase
  52.         private static char ToLowerAscii(char ch)
  53.         {
  54.             if ((ch >= 'A') && (ch <= 'Z'))
  55.             {
  56.                 return (char)(ch + ('a' - 'A'));
  57.             }
  58.             return ch;
  59.         } // ToLowerAscii
  60.         
  61.         
  62.     } // StringHelper
  63. // namespace System.Runtime.Remoting.Channels
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值