当前位置: 首页>>代码示例>>C#>>正文


C# String.StartsWith方法代码示例

本文整理汇总了C#中System.String.StartsWith方法的典型用法代码示例。如果您正苦于以下问题:C# String.StartsWith方法的具体用法?C# String.StartsWith怎么用?C# String.StartsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.String的用法示例。


在下文中一共展示了String.StartsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateLocator

        public static DomElementLocator GenerateLocator(String raw)
        {
            if (!raw.StartsWith(Constant.DOMElementPrefix))
            {
                return null;
            }

            LocatorMethod method;

            raw = raw.Substring(1);
            if (raw.StartsWith(Constant.DOMIDPrefix))
            {
                method = LocatorMethod.ID;
                raw = raw.Substring(Constant.DOMIDPrefix.Length);
            }
            else if (raw.StartsWith(Constant.DOMNamePrefix))
            {
                method = LocatorMethod.Name;
                raw = raw.Substring(Constant.DOMNamePrefix.Length);
            }
            else if (raw.StartsWith(Constant.DOMXPathPrefix))
            {
                method = LocatorMethod.XPath;
                raw = raw.Substring(Constant.DOMXPathPrefix.Length);
            }
            else
            {
                return null;
            }

            return new DomElementLocator(method, raw);
        }
开发者ID:TaikorInc,项目名称:FalcoA,代码行数:32,代码来源:TemplateGenHelper.cs

示例2: Clean

        public new String Clean(String value)
        {
            // get rid of commas
            value = StringUtils.ReplaceAnyOf(value, ",().-_", ' ');

            // do basic cleaning
            value = _sub.Clean(value);
            if (String.IsNullOrEmpty(value))
                return "";

            // perform pre-registered transforms
            value = base.Clean(value);

            // renormalize whitespace, since being able to replace tokens with spaces
            // makes writing transforms easier
            value = StringUtils.NormalizeWs(value);

            // transforms:
            // "as foo bar" -> "foo bar as"
            // "al foo bar" -> "foo bar al"
            if (value.StartsWith("as ") || value.StartsWith("al "))
                value = value.Substring(3) + ' ' + value.Substring(0, 2);

            return value;
        }
开发者ID:donners77,项目名称:DukeSharp,代码行数:25,代码来源:NorwegianCompanyNameCleaner.cs

示例3: GetValue

 private dynamic GetValue(Process p, String type, DeepPointer pointer)
 {
     if (type == "int")
         return pointer.Deref<int>(p);
     else if (type == "uint")
         return pointer.Deref<uint>(p);
     else if (type == "float")
         return pointer.Deref<float>(p);
     else if (type == "double")
         return pointer.Deref<double>(p);
     else if (type == "byte")
         return pointer.Deref<byte>(p);
     else if (type == "sbyte")
         return pointer.Deref<sbyte>(p);
     else if (type == "short")
         return pointer.Deref<short>(p);
     else if (type == "ushort")
         return pointer.Deref<ushort>(p);
     else if (type == "bool")
         return pointer.Deref<bool>(p);
     else if (type.StartsWith("string"))
     {
         var length = Int32.Parse(type.Substring("string".Length));
         return pointer.DerefString(p, length);
     }
     else if (type.StartsWith("byte"))
     {
         var length = Int32.Parse(type.Substring("byte".Length));
         return pointer.DerefBytes(p, length);
     }
     throw new ArgumentException(string.Format("The provided type, '{0}', is not supported", type));
 }
开发者ID:Dchapz,项目名称:LiveSplit.ScriptableAutoSplit,代码行数:32,代码来源:ASLState.cs

示例4: NormalizeIdentityUrl

        public static Uri NormalizeIdentityUrl(String identityUrl)
        {
            Uri retVal = null;
               // To get an iname to fit onto a Uri object, we prefix
               // with "xri:". This is because Uri object will not allow "xri://".
               if (identityUrl.StartsWith("xri://"))
               {
               identityUrl = identityUrl.Substring("xri://".Length);
               retVal = new Uri("xri:" + identityUrl);
               }
               else if (identityUrl.StartsWith("=") || identityUrl.StartsWith("@"))
               {
               retVal = new Uri("xri:" + identityUrl);
               }
               else if (!identityUrl.StartsWith("http://"))
               {
               retVal = Janrain.OpenId.UriUtil.NormalizeUri(string.Format("http://{0}/", identityUrl.Trim("/".ToCharArray())));

               }
               else
               {
               retVal = Janrain.OpenId.UriUtil.NormalizeUri(identityUrl);
               }
               return retVal;
        }
开发者ID:grrizzly,项目名称:3D-Repository,代码行数:25,代码来源:Utility.cs

示例5: point

        // accept either a POINT(X Y) or a "X Y"
        public point(String ps)
        {
            if (ps.StartsWith(geomType, StringComparison.InvariantCultureIgnoreCase))
            {
                // remove point, and matching brackets
                ps = ps.Substring(geomType.Length);
                if (ps.StartsWith("("))
                {
                    ps = ps.Substring(1);
                }
                if (ps.EndsWith(")"))
                {
                    ps = ps.Remove(ps.Length - 1);
                }

            }
            ps = ps.Trim(); // trim leading and trailing spaces
            String[] coord = ps.Split(CoordSeparator.ToCharArray());
            if (coord.Length == 2)
            {
                X = Double.Parse(coord[0]);
                Y = Double.Parse(coord[1]);
            }
            else
            {
                throw new WaterOneFlowException("Could not create a point. Coordinates are separated by a space 'X Y'");
            }
        }
开发者ID:CUAHSI,项目名称:CUAHSI-GenericWOF_vs2013,代码行数:29,代码来源:point.cs

示例6: MergeHttp

 public static String MergeHttp(String server, String path)
 {
     if (server.StartsWith("http:"))
     {
         server = server.Substring(5);
     }
     while (server.StartsWith("/"))
     {
         server = server.Substring(1);
     }
     while (server.EndsWith("/"))
     {
         server = server.Substring(0, server.Length - 1);
     }
     while (path.StartsWith("/"))
     {
         path = path.Substring(1);
     }
     if (path.StartsWith(":"))
     {
         return "http://" + server + "" + path;
     }
     else
     {
         return "http://" + server + "/" + path;
     }
 }
开发者ID:limingnihao,项目名称:Net,代码行数:27,代码来源:PathUtil.cs

示例7: process

        public void process( String s)
        {
            reply = s;

            if( reply.StartsWith("I:")){
                this.init();
            }
            else if( reply.StartsWith("S:")){
                this.setUp();
            }

            else if (reply.StartsWith("G:"))
            {
                this.update();
            }

            else if (reply.StartsWith("C:"))
            {
                this.coin();
            }

            else if (reply.StartsWith("L:"))
            {
                this.lifePack();
            }
        }
开发者ID:hansika,项目名称:TanksGameClient,代码行数:26,代码来源:AI.cs

示例8: ExecuteFlagAction

 /// <summary>
 /// Modifies the specified CommandBar item
 /// </summary>
 public static void ExecuteFlagAction(ToolStripItem item, String action, Boolean value)
 {
     if (action.StartsWith("Check:"))
     {
         if (item is ToolStripMenuItem)
         {
             ((ToolStripMenuItem)item).Checked = value;
         }
     }
     else if (action.StartsWith("Uncheck:"))
     {
         if (item is ToolStripMenuItem)
         {
             ((ToolStripMenuItem)item).Checked = !value;
         }
     }
     else if (action.StartsWith("Enable:"))
     {
         item.Enabled = value;
     }
     else if (action.StartsWith("Disable:"))
     {
         item.Enabled = !value;
     }
 }
开发者ID:Neverbirth,项目名称:flashdevelop,代码行数:28,代码来源:ButtonManager.cs

示例9: SendMessageCustomToken

        public static bool SendMessageCustomToken(String Channel, String Message, String Token)
        {
            APICaller apic = new APICaller(Token);
            bool returned = false;
            Dictionary<String, dynamic> Params = new Dictionary<string, dynamic>();

            if (Token.Equals("someone"))
            {
                Token = "xoxp-5007212458-11027941589-11025314452-ac4fcf3c3b";
            }
            else if (Token.Equals("timo"))
            {
                Token = "xoxb-5134150563-iZKW7CIodzRbffqVmFmz6m2S";
            }
            else if (Token.Equals("lily"))
            {
                Token = "xoxb-7444634401-UTU2IHZE2kULUWu70hgKV0FA";
            }

            if (Channel.StartsWith("C") || Channel.StartsWith("D"))
            {
                Params.Add("channel", Channel);
                Params.Add("text", Message);
                Params.Add("as_user", "true");
                Params.Add("token", Token);
                returned = apic.CallMethodCustomToken("chat.postMessage", Params).Result["ok"];
            }
            Console.WriteLine("Posted message: " + Message + " to Channel: " + Channel + " with return code: " + returned);
            return returned;
        }
开发者ID:L3tum,项目名称:SlackAPI,代码行数:30,代码来源:SlackClient.cs

示例10: UpdateApp

 public void UpdateApp(XApplication app, String path, XAppInstallListener listener)
 {
     bool isAbsolute = path.StartsWith("/") || path.StartsWith("\\");
     String tmp = isAbsolute ? path : ResolvePathUsingWorkspace(app.GetWorkSpace(), path);
     String abspath = XUtils.BuildabsPathOnIsolatedStorage(tmp);
     appManagement.UpdateApp(abspath, listener);
 }
开发者ID:polyvi,项目名称:xface-extension-ams,代码行数:7,代码来源:XAmsImpl.cs

示例11: removeFirstSlash

        public static String removeFirstSlash(String path)
        {
            if (path.StartsWith("/") || path.StartsWith("\\") )
                return path.Substring(1);

            return path;
        }
开发者ID:rrmartins,项目名称:rhodes,代码行数:7,代码来源:RhoFilePath.cs

示例12: Address

 public Address(String sourceAddressCode)
 {
     if (sourceAddressCode.StartsWith(LexicalSymbols.LabelAddress))
     {
         this.IsLabelledAddress = true;
         this.AddressLabel = sourceAddressCode.Replace(LexicalSymbols.LabelAddress, String.Empty);
     }
     else if (sourceAddressCode.StartsWith(LexicalSymbols.BinaryAddress))
     {
         this.BinaryAddress = int.Parse(sourceAddressCode.Replace(LexicalSymbols.BinaryAddress, String.Empty));
         this.SourceAddress = BinaryToSource(this.BinaryAddress);
     }
     else
     {
         this.SourceAddress = int.Parse(sourceAddressCode);
         if (this.SourceAddress >= 0)
         {
             this.BinaryAddress = SourceToBinary(this.SourceAddress);
         }
         else
         {
             this.BinaryAddress = this.SourceAddress;
         }
     }
 }
开发者ID:Creou,项目名称:OISCVM,代码行数:25,代码来源:Address.cs

示例13: CreateHttpHandler

 //- ~CreateHttpHandler -//
 internal static IHttpHandler CreateHttpHandler(String text)
 {
     IHttpHandler handler = null;
     if (!text.StartsWith("{") && text.Contains(","))
     {
         return ObjectCreator.CreateAs<IHttpHandler>(text);
     }
     //+
     if (!text.StartsWith("{") && RouteCache.HandlerFactoryCache != null)
     {
         String lowerCaseText = text.ToLower(CultureInfo.CurrentCulture);
         List<IFactory> handlerFactoryList = RouteCache.HandlerFactoryCache.GetValueList();
         foreach (IFactory factory in handlerFactoryList)
         {
             handler = ((HandlerFactory)factory).CreateHttpHandler(lowerCaseText);
             if (handler != null)
             {
                 break;
             }
         }
     }
     if (handler == null && text.StartsWith("{"))
     {
         text = text.Substring(1, text.Length - 2);
         List<Type> list = ScannedTypeCache.GetTypeData("httpHandler");
         Type httpHandlerType = list.SingleOrDefault(p => p.Name == text + "HttpHandler");
         if (httpHandlerType != null)
         {
             handler = ObjectCreator.CreateAs<IHttpHandler>(httpHandlerType);
         }
     }
     //+
     return handler;
 }
开发者ID:davidbetz,项目名称:themelia,代码行数:35,代码来源:HttpHandlerSelector.cs

示例14: TraceSimpleEvent

        protected override void TraceSimpleEvent(DateTime eventTime, Int32 threadId, TraceEventType eventType, String message, Int32 eventId, TraceEventCache eventCache, String source)
        {
            if (_table != null)
            {
                if (message.StartsWith("#Status ") || message.StartsWith("#Status:"))
                {
                    Status status = new Status(eventTime.ToUniversalTime());
                    status.Level = eventType.ToString();
                    status.ThreadId = threadId;

                    string messageText;
                    string dataText;
                    GetMessageParts(message, out messageText, out dataText);
                    status.Message = messageText;
                    status.Data = dataText;

                    try
                    {
                        TableOperation operation = TableOperation.Insert(status);
                        this._table.Execute(operation);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception while saving to Azure storage.");
                        Console.WriteLine(e.ToString());
                        throw;
                    }
                }
            }
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:30,代码来源:AzureTableStorageStatusTraceListener.cs

示例15: TryMapNamespace

		/// <summary>
		/// Tries to the map the C# to JS namespace.
		/// </summary>
		/// <param name="serverNs">The namespace.</param>
		/// <param name="clientNs">The client namespace.</param>
		/// <returns></returns>
        public bool TryMapNamespace(String serverNs, out string clientNs)
        {
            foreach (var m in namespaceMapping)
                switch (m.Mode)
                {
                    case NamespaceMappingMode.Exact:
                        if (m.Namespace == serverNs)
                        {
                            clientNs = m.ClientNamespace;
                            return true;
                        }
                        break;
                    case NamespaceMappingMode.Prefix:
                        if (serverNs.StartsWith(m.Namespace))
                        {
                            clientNs = m.ClientNamespace + serverNs.Substring(m.Namespace.Length);
                            return true;
                        }
                        break;
                    case NamespaceMappingMode.PrefixExact:
                        if (serverNs.StartsWith(m.Namespace))
                        {
                            clientNs = m.ClientNamespace;
                            return true;
                        }
                        break;
                }                
            clientNs = null;
            return false;
        }
开发者ID:borisdj,项目名称:dextop,代码行数:36,代码来源:DextopModule.Namespaces.cs


注:本文中的System.String.StartsWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。