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


C# String.Contains方法代码示例

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


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

示例1: ConvertValue

 private static string ConvertValue(String value)
 {
     Dictionary<String, String> replacements = new Dictionary<string, string>();
     replacements.Add("&sp;", " ");
     replacements.Add("&1uc;", "{-|}");
     replacements.Add("&amp;", "&");
     replacements.Add("&bs;", "{# BackSpace}");
     replacements.Add("&cr;", "{# Return}");
     replacements.Add("&uc;", "{MODE:CAPS}");
     replacements.Add("&lc;", "{MODE:LOWER}");
     replacements.Add("&dw;", "{# Control_L(BackSpace)}");
     replacements.Add("\\", "\\\\");
     replacements.Add("\"", "\\\"");
     foreach (string key in replacements.Keys.OrderByDescending(_k=>_k.Length))
     {
         value = value.Replace(key, replacements[key]);
     }
     if (value.Contains("&+i;"))
     {
         value = String.Format("{0}{{^}}", value.Replace("&+i;", ""));
     }
     if (value.Contains("&rb;"))
     {
         value = String.Format("{{^}}{0}", value.Replace("&rb;", ""));
     }
     return value.Trim();
 }
开发者ID:Skaaal,项目名称:StenturaArduino,代码行数:27,代码来源:PloverEntry.cs

示例2: GenerateIntoClass

        public static void GenerateIntoClass(
            String targetFile, String @namespace, String classDeclaration, Action<StringBuilder> logic)
        {
            var buffer = new StringBuilder();
            logic(buffer);

            using (var targetFileWriter = new StreamWriter(targetFile))
            {
                targetFileWriter.WriteLine(Constants.CodegenDisclaimer);
                targetFileWriter.WriteLine();

                var textGeneratedIntoClass = typeof(Helpers).Assembly.ReadAllText("Truesight.TextGenerators.Core.TextGeneratedIntoClass.template");
                textGeneratedIntoClass = textGeneratedIntoClass
                    .Replace("%NAMESPACE_NAME%", @namespace)
                    .Replace("%CLASS_DECLARATION%", classDeclaration)
                    .Replace("%GENERATED_TEXT%", buffer.ToString());

                if (classDeclaration.Contains("enum") || classDeclaration.Contains("interface"))
                {
                    textGeneratedIntoClass = textGeneratedIntoClass
                        .Replace("    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]" + Environment.NewLine, "");
                }

                targetFileWriter.Write(textGeneratedIntoClass);
            }
        }
开发者ID:xeno-by,项目名称:truesight-lite,代码行数:26,代码来源:Helpers.cs

示例3: addLinksToString

        public string addLinksToString(String myString)
        {
            string[] temp = myString.Split(' '); //split into words
            if (myString.Contains("http:") || myString.Contains("www."))
            {
                for (int i = 0; i < temp.Length; i++)
                {
                    if (temp[i].Contains("www.") && (!temp[i].Contains("http")))
                    {
                        temp[i] = "<a href=\"http://" + temp[i] + "\">" + temp[i] + "</a>";
                    }
                    else if (temp[i].Contains("http://"))
                    {
                        temp[i] = "<a href=\"" + temp[i] + "\">" + temp[i] + "</a>";
                    }
                }

            }
            string result = "";
            foreach (string item in temp)
            {
                result += item + " ";
            }
            return result;
        }
开发者ID:WaitakiDC,项目名称:Sharepoint-2013-Webparts,代码行数:25,代码来源:VisualWebPart1UserControl.ascx.cs

示例4: transform_to_review3_tvmTokens

        // This method is made only for not having to remake the bar codes on the cards for the review 3
        // NP sets are called tvm_xxx while the cards show token xxx
        public static String transform_to_review3_tvmTokens(String scannedToken)
        {

            
            if (scannedToken.Contains("sammy"))
            {
                return "tvm_sammy";
            }
            else if (scannedToken.Contains("lara"))
            {
                return "tvm_lara";
            }
            else if (scannedToken.Contains("jasmin"))
            {
                return "tvm_valdimir"; ;
            }
            else if (scannedToken.Contains("vladimir"))
            {
                return "tvm_valdimir";
            }
            else
            {
                return "logout";
            }
        }
开发者ID:cstrobbe,项目名称:C4A-TVM,代码行数:27,代码来源:GPIIAdapter.cs

示例5: ParseJson

        public void ParseJson(String jstring)
        {
            if (jstring.Contains("recording"))
            {
                if (jstring.Contains("true"))
                {
                    Console.WriteLine("Starting!");
                    recording = true;
                }
                else
                {
                    Console.WriteLine("Stopping!");
                    List<WriterAction> nactions = new List<WriterAction>(actions.Count);
                    actions.ForEach(nactions.Add);
                    new Thread(GUI.StartGui).Start(nactions);
                    actions.Clear();
                    recording = false;
                }
                return;
            }
            var json = new DataContractJsonSerializer(typeof (UserAction));
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(jstring));
            UserAction act = json.ReadObject(stream) as UserAction;
            stream.Close();

            if (recording)
            {
                Console.WriteLine(act.ToString());
                actions.Add(act);
            }
        }
开发者ID:bwackwat,项目名称:PageObjectGenerator,代码行数:31,代码来源:Receiver.cs

示例6: NonBooleanConstraint

        /// <summary>
        /// Creates a new NonBooleanConstraint for a expression. The expression have to consist binary and numeric options and operators such as "+,*,>=,<=,>,<, and =" only. 
        /// Where all binary and numeric options have to be defined in the variability model. 
        /// </summary>
        /// <param name="unparsedExpression"></param>
        /// <param name="varModel"></param>
        public NonBooleanConstraint(String unparsedExpression, VariabilityModel varModel)
        {
            if (unparsedExpression.Contains(">="))
            {
                comparator = ">=";
            }
            else if (unparsedExpression.Contains("<="))
            {
                comparator = "<=";
            }
            else if (unparsedExpression.Contains("="))
            {
                comparator = "=";
            }
            else if (unparsedExpression.Contains(">"))
            {
                comparator = ">";
            }
            else if (unparsedExpression.Contains("<"))
            {
                comparator = "<";
            }

            String[] parts = unparsedExpression.Split(comparator.ToCharArray());
            leftHandSide = new InfluenceFunction(parts[0], varModel);
            rightHandSide = new InfluenceFunction(parts[parts.Length-1], varModel);
        }
开发者ID:AlexanderGrebhahn,项目名称:SPLConqueror,代码行数:33,代码来源:NonBooleanConstraint.cs

示例7: foundBySpecifiedCase

 /** Used to figure out whether a Contains search will use an Ordinal or OrdinalIgnoreCase
  *  Default int of 0 is to ignore case (and return more search findings).
  **/
 public static Boolean foundBySpecifiedCase(String toFind, String toSearchIn, int caseSensitive)
 {
     if (caseSensitive == 0)
         return toSearchIn.Contains(toFind, StringComparison.OrdinalIgnoreCase);
     else
         return toSearchIn.Contains(toFind);
 }
开发者ID:straboulsi,项目名称:fauvel,代码行数:10,代码来源:Search.cs

示例8: processCommand

      public void processCommand(String c, MainWindow main)
        {

            c = c.ToLower();
            main.log.Items.Add(DateTime.Now + ": " + c);


            if (!c.Contains("xbox")) //Because I have a xbox one (Prevents jarvis from picking up xbox commands)
  
      if (c.Contains("sleep"))
          {
              ExecuteCommand("C:/nircmd.exe monitor off");
          }
      else
      {
          if (JarvisData.isOff != "true")
          {
              t = new Thread(ProcessCommand2);
              t.Start(c);
          }
         
      }
          
          
        }
开发者ID:RedEyedDog,项目名称:Jarvis,代码行数:25,代码来源:Commands.cs

示例9: Hokuyo

        public Hokuyo(LidarID lidar)
        {
            //trameDetails = "VV\n00P\n";
            this.lidar = lidar;
            semLock = new Semaphore(1, 1);

            switch (lidar)
            {
                case LidarID.LidarSol: model = "URG-04LX-UG01"; break;
            }

            if (model.Contains("UBG-04LX-F01"))//Hokuyo bleu
            {
                nbPoints = 725;
                angleMesurable = new Angle(240, AnglyeType.Degre);
                offsetPoints = 44;
            }
            else if (model.Contains("URG-04LX-UG01")) //Petit hokuyo
            {
                nbPoints = 725;
                angleMesurable = new Angle(240, AnglyeType.Degre);
                offsetPoints = 44;
            }
            else if (model.Contains("BTM-75LX")) // Grand hokuyo
            {
                nbPoints = 1080;
                angleMesurable = new Angle(270, AnglyeType.Degre);
                offsetPoints = 0;
            }

            position = Robots.GrosRobot.Position;

            Robots.GrosRobot.PositionChange += GrosRobot_PositionChange;
        }
开发者ID:KiwiJaune,项目名称:GoBot,代码行数:34,代码来源:Hokuyo.cs

示例10: getEncrypted

 /*
 //[DllImport("Backend.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
 DEPRECATED DLL USAGE
 [DllImport("Backend.dll")]
 public static extern void getEncrypted(StringBuilder expression, StringBuilder key, bool isFile);
 [DllImport("Backend.dll")]
 public static extern void getDecrypted(StringBuilder expression, StringBuilder key, bool isFile);
 */
 /*
 public static String encryptExpression(String expression, String key)
 {
     string encryptedBuffer = new string(expression.Length * 10);
     //creates a string pointer(mutable) that my DLL can use to write the string.
     getEncrypted(expression, key, encryptedBuffer, expression.Length * 10);
     //TODO: fix string buffer size issues(look into how to make it resizeable?)
     //TODO: fix issue where random characters are sometimes returned at the end of the string
     return encryptedBuffer.ToString();
 }
 public static String decryptExpression(String ciphertext, String key)
 {
     string decryptedBuffer = new string(ciphertext.Length);
     getDecrypted(ciphertext, key, decryptedBuffer, ciphertext.Length);
     return decryptedBuffer.ToString();
 }
 */
 public static String encryptExpression(String expression, String key)
 {
     //using (FileStream stream = File.Create("return")) { } //create file and close stream automatically
     if (key.Contains("steg") && !key.Contains(Program.mediaFilePath)) //check if file is specified in key
         key += "=" + Program.mediaFilePath;
     #region Create headless backend exe process
     Process backend = createBackendProcess("\"" + expression + "\" \"" + key + "\" 1 " + (Program.usingFile ? "1" : "0"));
     backend.Start();
     backend.WaitForExit();
     #endregion
     //getEncrypted(expressionData, keyData, Program.usingFile);
     String errors = backend.StandardError.ReadToEnd();
     if(!errors.Equals(""))
     {
         if (MessageBox.Show("An error occured during your last encryption run. Display the message?", "Error", MessageBoxButtons.YesNo) == DialogResult.Yes)
             MessageBox.Show(errors, "Error Details");
     }
     return backend.StandardOutput.ReadToEnd();
     /*
     string encrypted;
     using (StreamReader read = new StreamReader(File.OpenRead("return"), Encoding.Default, true))
         encrypted = read.ReadToEnd();
     File.Delete("return");
     return encrypted;
     */
 }
开发者ID:dibgus,项目名称:Xipher-Solutions,代码行数:51,代码来源:BackendHandler.cs

示例11: cDataCheck

 public String cDataCheck(String input)
 {
     if (input.Contains("&") || input.Contains(">") || input.Contains("<"))
     {
         input = "<![CDATA[" + input + "]]>";
     }
     return input;
 }
开发者ID:robspages,项目名称:ExternalizedStringConverter,代码行数:8,代码来源:ExcelToXLIFF.cs

示例12: IsNotScript

        /// <summary>
        /// Checks the string input for script and html tags. This is a very rough check!
        /// </summary>
        /// <param name="value"></param>
        /// <returns>1 - Clean string | 2 - Scripts detected</returns>
        static public bool IsNotScript(String value)
        {
            if (value.Contains("<script>") || value.Contains("<html>"))
            {
                return false;
            }

            return true;
        }
开发者ID:Cosmin-Parvulescu,项目名称:Event.NET,代码行数:14,代码来源:Verification.cs

示例13: getNL

        public String getNL(String hand)
        {
            //only nl200
            String[] temp = hand.Split('(');
            String[] temp2 = temp[1].ToString().Split(')');

            if (hand.Contains("0.01/") && hand.Contains("0.02"))
            {
                return "2";
            }
            if (hand.Contains("0.02/") && hand.Contains("0.05"))
            {
                return "5";
            }
            if (hand.Contains("0.05/") && hand.Contains("0.10"))
            {
                return "10";
            }
            if (hand.Contains("0.08/") && hand.Contains("0.16"))
            {
                return "16";
            }
            if (temp2[0].Contains("0.10/") && temp2[0].Contains("0.20"))
            {
                return "20";
            }
            if (hand.Contains("0.10/") && hand.Contains("0.25"))
            {
                return "25";
            }
            if (hand.Contains("0.15/") && hand.Contains("0.30"))
            {
                return "30";
            }
            if (hand.Contains("0.25/") && hand.Contains("0.50"))
            {
                return "50";
            }
            if (hand.Contains("0.50/") && hand.Contains("1.00"))
            {
                return "100";
            }
            if (temp2[0].Contains("1/") && temp2[0].Contains("2") && !temp2[0].Contains("."))
            {
                return "200";
            }
            if (temp2[0].Contains("2/") && temp2[0].Contains("4") && !temp2[0].Contains("."))
            {
                return "400";
            }
            if (hand.Contains("2.50/") && hand.Contains("5.00"))
            {
                return "500";
            }
            return "_";
        }
开发者ID:ricain59,项目名称:fortaff,代码行数:56,代码来源:AppendToFile.cs

示例14: ExtractValuableInfo

        private static String ExtractValuableInfo( String inLine )
        {
            String retVal = "";

              // detect what we would like to find..
              if ( inLine.Contains( "Log Started" ) ) return String.Format("\t{0}\n", inLine);
              if ( inLine.Contains( "ProductVersion" ) ) return String.Format( "\t{0}\n", inLine );
              if ( inLine.Contains( "> Creating" ) ) return String.Format( "\t{0}\n", inLine );
              return retVal;
        }
开发者ID:robsneeds,项目名称:SCJMapper-V2,代码行数:10,代码来源:SCLogExtract.cs

示例15: ToFloat

        public static float ToFloat(String str)
        {
            if(!str.Contains(',') && !str.Contains('.')) 
                return float.Parse(str);

            string realSep = (float.Parse("0.5") == 0.5f) ? "." : ",";
            string strSep = str.Contains(".") ? "." : ",";

            return float.Parse(str.Replace(strSep, realSep));
        }
开发者ID:lcnvdl,项目名称:cscommon,代码行数:10,代码来源:Parsing.cs


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