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


C# String.Remove方法代码示例

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


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

示例1: NetworkShare

 /// <summary>
 /// Constructor with UNC
 /// </summary>
 /// <param name="path">The share name - UNC</param>
 public NetworkShare( String path )
 {
     String hostName = "";
     // check if the UNC is valid
     unc = (String) path.Clone();
     if( path.StartsWith( @"\\" ) )
     {
         path = path.Remove( 0, 2 );
         int i = path.IndexOf( @"\" );
         if( i < 0 )
         {
             goto _abort;
         }
         hostName = path.Substring( 0, path.IndexOf( @"\" ) );
         path = path.Remove( 0, i );
         if( path == null || path.Length < 1 )
         {
             goto _abort;
         }
         // remove the first "\"
         remotePath = (String) path.Remove( 0, 1 );
         if( remotePath == null || remotePath.Length < 1 )
         {
             goto _abort;
         }
         goto _ok;
     }
     _abort:
     throw new Exception( "Invalid UNC path: " + unc );
     _ok:
     {
         host = new NetworkHost( hostName, 0 /* dummy */ );
     }
 }
开发者ID:BackupTheBerlios,项目名称:shareindex,代码行数:38,代码来源:NetworkShare.cs

示例2: ChangeChair

        public ActionResult ChangeChair(Guid appointmentid, String id)
        {
            try
            {
                appointment appointment = db.appointments.SingleOrDefault(a => a.appointmentid == appointmentid);

                id = id.Remove(0, id.Length - 10);
                id = id.Remove(id.Length - 1);

                if (appointment != null)
                {
                    appointment.employeeid = id;

                    db.appointments.Attach(appointment);
                    db.ObjectStateManager.ChangeObjectState(appointment, EntityState.Modified);

                    ChangeChairEmail(appointment);

                    return Json("200");
                }
                return Json("503");
            }
            catch (Exception ex)
            {
                return View();
            }
            finally
            {
                db.SaveChanges();
            }
        }
开发者ID:LomnickiLucas,项目名称:AdvisementSys,代码行数:31,代码来源:CalandarController.cs

示例3: fromJSON

        public Dictionary<String, String> fromJSON(String json)
        {
            Dictionary<String, String> dict = new Dictionary<String, String>();

            Char[] splits = new Char[1];
            splits[0] = ',';

            if (!String.IsNullOrEmpty(json))
            {
                json = json.Trim();

                // Remove leading and trailing breakets
                if (json.StartsWith("{"))
                {
                    json = json.Remove(0, 1);
                    json = json.TrimStart();
                }
                if (json.EndsWith("}"))
                {
                    json = json.Remove(json.Length - 1);
                    json = json.TrimEnd();
                }

                String[] jsonItems = json.Split(splits, StringSplitOptions.RemoveEmptyEntries);

                // iterate all comma-separeted key-value-pairs
                for (int i = 0; i < jsonItems.Length; i++)
                {
                    String currentPart = jsonItems[i];
                    // check if it's a 'real' item-separator or maybe a comma inside a 'marked' string
                    if (checkForConsistentQuotes(currentPart) && currentPart.Contains(":"))
                    {
                        processKeyValuePair(dict, currentPart);
                    }
                    // we splitted inside a string, so do some error-handling
                    else if (i < jsonItems.Length - 1)
                    {
                        // add upcoming parts as long as we do not have a 'working' part
                        do
                        {
                            i++;
                            currentPart += "," + jsonItems[i];
                        }
                        while (!(checkForConsistentQuotes(currentPart) && currentPart.Contains(":")));

                        processKeyValuePair(dict, currentPart);
                    }
                }
            }

            return dict;
        }
开发者ID:pdiegmann,项目名称:net-reaktor,代码行数:52,代码来源:JSONConverter.cs

示例4: ChangeExtension

 public static String ChangeExtension(String Path,String Ext)
 {
     int sindex = Path.LastIndexOf('.');
     if (sindex == -1)
         return Path;
     return Path.Remove(sindex) + '.' + Ext.Trim(' ', '.').ToLower();
 }
开发者ID:Rarder44,项目名称:ExtendCSharp,代码行数:7,代码来源:SystemService.cs

示例5: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            this.cmdSignOut.ServerClick += new System.EventHandler(this.cmdSignOut_ServerClick);

            tempUserList = new List<String>();
            tempController = new Controller.Controller();

            //Hämtar username från session och skriver ut username.
            userN = (string)(Session["userName"]);

            LoggedInUser.Text = "Logged in: " + userN.Remove(1).ToUpper() + userN.Substring(1) + " >> " + tempController.GetUserRole(userN);

            //Hämtar userID från session.

            userID = (int)(Session["userID"]);

            Session["SelectedDrop"] = DropDownListReceivers.SelectedIndex;

            FillDropDownUsers();

            if (!Page.IsPostBack) {
                TextBoxSubject.Text = "Subject..";
            }

            CheckIfReply();
            CheckIfForward();
        }
开发者ID:Elpulgo,项目名称:PulgoIntranet,代码行数:27,代码来源:ComposeMail.aspx.cs

示例6: GetExpectedMethodName

		static String GetExpectedMethodName( String path )
		{
			//WARN: questo è un bug: impedisce di chiamare effettivamente il metodo nel VM qualcosa del tipo FooCommand perchè noi cercheremmo solo Foo
			var methodName = path.EndsWith( "Command" ) ? path.Remove( path.LastIndexOf( "Command" ) ) : path;

			return methodName;
		}
开发者ID:micdenny,项目名称:Radical.Windows,代码行数:7,代码来源:DelegateCommandBuilder.cs

示例7: 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

示例8: convert

        public String convert()
        {
            if (!Sauce.StartsWith("Hai 1.2"))
            {
                return new SyntaxErrorException("No 'Hai 1.2' starting command!").ToString();
            }
            Sauce = Sauce.Remove(0, 7);
            if (!Sauce.EndsWith("KTHXBYE"))
            {
                return new SyntaxErrorException("No KTHXBYE ending command!").ToString();
            }
            else
            {
                Sauce = Sauce.Remove(Sauce.Length - 8);
            }

            #region Pattern
            pattern.Add(@"I HAS A ([a-zA-Z]+)( ITZ )([a-zA-Z0-9\.]+)"); //Variable declaration and init
            pattern.Add(@"I HAS A ([a-zA-Z]+)"); //Only declaration
            pattern.Add(@"([a-zA-Z]+) R (""?[a - zA - Z0 - 9\.] + ""?)"); //only init
            pattern.Add(@",? *	*BTW"); //One line comment
            pattern.Add(@",? *	*OBTW"); //Multi line comment 1.
            pattern.Add(@",? *	*TLDR"); //Multi line comment 2.
            pattern.Add(@"WIN"); //truec
            pattern.Add(@"FAIL"); //false
            pattern.Add(@","); //Line breaks
            pattern.Add(@"YARN"); //String
            pattern.Add(@"NUMBR"); //int
            pattern.Add(@"NUMBAR"); //float
            pattern.Add(@"TROOF"); //bool
            pattern.Add(@"NOOB"); //untyped
            pattern.Add(@"(""[a-zA-Z0-9.]*)(:\))([a-zA-Z0-9.]*"")"); //newline in String
            pattern.Add(@"(""[a-zA-Z0-9.]*)(:\>)([a-zA-Z0-9.]*"")"); //tab in String
            pattern.Add(@"(""[a-zA-Z0-9.]*)(:o)([a-zA-Z0-9.]*"")"); //beep in String
            pattern.Add(@"(""[a-zA-Z0-9.]*)(:"")([a-zA-Z0-9.]*"")"); //literal quote in String
            pattern.Add(@"(""[a-zA-Z0-9.]*)(::)([a-zA-Z0-9.]*"")"); //: in String
            pattern.Add(Util.Util.getNewLineInString(Sauce) + @"? *   *(\.\.\.) ?" + Util.Util.getNewLineInString(Sauce) + @" *   *([a-zA-Z0-9 .]+)"); //Line continuation
            pattern.Add(@"[^{};](" + Util.Util.getNewLineInString(Sauce) + @")"); //obvsl new line
            #endregion
            #region replacements
            replacements.Add(@"var $1 = $2;" + Util.Util.getNewLine());
            replacements.Add(@"var $1;" + Util.Util.getNewLine());
            replacements.Add(@"$1 = $2;" + Util.Util.getNewLine());
            replacements.Add(@"//");
            replacements.Add(@"/\*");
            replacements.Add(@"\*/");
            replacements.Add(@"true");
            replacements.Add(@"false");
            replacements.Add(Util.Util.getNewLine());
            replacements.Add(@"$2");
            replacements.Add(@";" + Util.Util.getNewLine());
            #endregion

            for (int i = 0; i < pattern.Count; i++)
            {
                Sauce = Regex.Replace(Sauce, pattern[i], replacements[i]);
            }

            return Sauce;
        }
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:60,代码来源:LolcodeInterpreter.cs

示例9: ResultOfApiCall

        internal string ResultOfApiCall(string functionName)
        {
            var resultString = new String(Convert.ToChar(0), 129);
           
            try
            {
                // Returns the result code for the last API call.

                int resultCode = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

                // Get the result message that corresponds to the code.
                long temp = 0;

                var bytes = NativeMethods.FormatMessage(NativeMethods.FormatMessageFromSystem, ref temp, resultCode, 0, resultString, 128, 0);

                // Subtract two characters from the message to strip the CR and LF.
                if (bytes > 2)
                {
                    resultString = resultString.Remove(bytes - 2, 2);
                }

                // Create the String to return.
                resultString = Environment.NewLine + functionName + Environment.NewLine + "Result = " + resultString + Environment.NewLine;

            }
            catch (Exception)
            {
                return string.Empty;
            }

            return resultString;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:32,代码来源:Debugging.cs

示例10: convertFrom

        public Returnstack convertFrom(String wert)
        {
            Returnstack result = new Returnstack ();

            if (!this.analyse (wert)) {
                result = new Returnstack ("Falsche Syntax!\nEs sind nur die Zeichen '0-1' erlaubt.");
                result.addStep("Analyse ergabe Fehler in der Syntax.");
                return result;
            }

            String vorzeichen = "";
            if (wert [0] == '1') {
                wert = wert.Remove (0, 1);
                vorzeichen = "-";
            }

            Returnstack dezimal = new Binaer ().convertToDez (new Dualoperationen ().invert (wert));

            String steps = "";
            for (int i = 0; i< dezimal.getSteps().Length; i++) {
                steps += dezimal.getSteps() [i] + "|";
            }

            result.setResult (vorzeichen + dezimal.getResult ());
            result.addStep (steps);
            return result;
        }
开发者ID:SnowFace,项目名称:Rechnerstrukturen,代码行数:27,代码来源:EinerKomp.cs

示例11: SaveTextToFile

        public static bool SaveTextToFile(String _File, String _Text, bool _Append)
        {
            String var_Path = _File.Remove(_File.LastIndexOf("/"));

            if (CreatePath(var_Path))
            {
                try
                {
                    StreamWriter writer;

                    if (_Append)
                    {
                        writer = new StreamWriter(File.Open(_File, FileMode.Append));
                    }
                    else
                    {
                        writer = new StreamWriter(File.Open(_File, FileMode.CreateNew));
                    }

                    writer.Write(_Text);
                    writer.Flush();
                    writer.Close();
                    return true;
                }
                catch
                {
                    // Error!
                }
            }
            else
            {
                // Error!
            }
            return false;
        }
开发者ID:Gothen111,项目名称:2DWorld,代码行数:35,代码来源:IOManager.cs

示例12: GetPropertyValue

        public static Object GetPropertyValue(Object obj, String property)
        {
            try
            {
                if (property.Contains("."))
                {
                    String objProp = property.Remove(property.IndexOf("."));
                    String prop = property.Substring(property.IndexOf(".") + 1);

                    if (objProp == obj.GetType().Name)
                    {
                        return GetPropertyValue(obj, prop);
                    }
                    else
                    {
                        Object newObj = obj.GetType().GetProperty(objProp).GetValue(obj, null);
                        return GetPropertyValue(newObj, prop);
                    }
                }
                else
                {
                    return obj.GetType().GetProperty(property).GetValue(obj, null);
                }
            }
            catch (ApplicationException exc)
            {
                throw new ApplicationException(String.Format("Cannot find property: {0} ({1})", property, exc.Message));
            }
        }
开发者ID:marciotoshio,项目名称:Pigeon-Mailer,代码行数:29,代码来源:ReflectionHelper.cs

示例13: convertTo

        public Returnstack convertTo(String wert)
        {
            Returnstack result = new Returnstack ();

            if (!this.analyse (wert)) {
                result = new Returnstack ("Falsche Syntax!\nEs sind nur die Zeichen '0-9' und '-' erlaubt.");
                result.addStep ("Analyse ergabe Fehler in der Syntax.");
                return result;
            }

            Returnstack dezimal = new Dezimal ().convertToBin (wert);

            String steps = "";
            for (int i = 0; i< dezimal.getSteps().Length; i++) {
                steps += dezimal.getSteps () [i] + "|";
            }

            if (wert [0] == '-') {
                wert = wert.Remove (0, 1);
                result.setResult ("1" + new Dualoperationen ().invert (dezimal.getResult ()));

            } else {
                result.setResult (dezimal.getResult ());
            }

            result.addStep (steps);
            return result;
        }
开发者ID:SnowFace,项目名称:Rechnerstrukturen,代码行数:28,代码来源:EinerKomp.cs

示例14: evaluate

 public void evaluate(String data, Form1 com)
 {
     this.com = com;
     this.data = data;
     data = data.Remove(data.Length - 1);
     string[] lines = Regex.Split(data, ":");    //split recevied data sting and split it :
     if (lines[0] == "I")                        //Check 1st part of the server msg
     {                                           //if 1st letter I means initiate game map
         initiate_Evaluate(lines, com);
     }
     else if (lines[0] == "C")                   // C means new coin created in the map
     {
         coin(lines, com);
     }
     else if (lines[0] == "S"){                  // S means players initiate
         newPlayer(lines);
     }
     else if (lines[0] == "G")                   // G means Game world updates
     {
        tankMoves(lines);
     }
     else if (lines[0] == "L")                   // L means life packet
     {
         life(lines, com);
     }
 }
开发者ID:Jayancv,项目名称:TankJC,代码行数:26,代码来源:stringEvaluator.cs

示例15: ResultOfAPICall

        ///  <summary>
        ///  Get text that describes the result of an API call.
        ///  </summary>
        ///  
        ///  <param name="FunctionName"> the name of the API function. </param>
        ///  
        ///  <returns>
        ///  The text.
        ///  </returns>

        public String ResultOfAPICall(String functionName) 
        {             
            Int32 bytes = 0; 
            Int32 resultCode = 0; 
            String resultString = ""; 
            
            resultString = new String(Convert.ToChar( 0 ), 129 ); 
            
            // Returns the result code for the last API call.
            
            resultCode = System.Runtime.InteropServices.Marshal.GetLastWin32Error(); 
            
            // Get the result message that corresponds to the code.

            Int64 temp = 0;          
            bytes = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, ref temp, resultCode, 0, resultString, 128, 0); 
            
            // Subtract two characters from the message to strip the CR and LF.
            
            if ( bytes > 2 ) 
            { 
                resultString = resultString.Remove( bytes - 2, 2 ); 
            }             
            // Create the String to return.
            
            resultString = "\r\n" + functionName + "\r\n" + "Result = " + resultString + "\r\n"; 
            
            return resultString;             
        }         
开发者ID:raipat,项目名称:nia-brew,代码行数:39,代码来源:Debugging.cs


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