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


C# StringBuilder.ToString方法代码示例

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


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

示例1: ReadTXFNChunk

        private void ReadTXFNChunk(BinaryReader bin, BlizzHeader chunk)
        {
            //List of BLP filenames
            var blpFilesChunk = bin.ReadBytes((int)chunk.Size);

            var str = new StringBuilder();

            for (var i = 0; i < blpFilesChunk.Length; i++)
            {
                if (blpFilesChunk[i] == '\0')
                {
                    if (str.Length > 1)
                    {
                        str.Replace("..", ".");
                        str.Append(".blp"); //Filenames in TEX dont have have BLP extensions
                        if (!CASC.FileExists(str.ToString()))
                        {
                            new WoWFormatLib.Utils.MissingFile(str.ToString());
                        }
                    }
                    str = new StringBuilder();
                }
                else
                {
                    str.Append((char)blpFilesChunk[i]);
                }
            }
        }
开发者ID:Ser0ja,项目名称:WoWFormatTest,代码行数:28,代码来源:TEXReader.cs

示例2: OnActionExecuting

        public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
        {

            if (actionContext.ModelState.IsValid) return;

            var errors = actionContext.ModelState
                .Where(e => e.Value.Errors.Count > 0)
                .Select(e => new Error
                {
                    Name = e.Key,
                    Message = e.Value.Errors.First().ErrorMessage ?? e.Value.Errors.First().Exception.Message
                }).ToArray();

            var strErrors = new StringBuilder();
            foreach (var error in errors)
            {
                var errorM = String.IsNullOrEmpty(error.Message) ? "Invalid Value" : error.Message;
                strErrors.Append(string.Format("[{0}]:{{{1}}}/", error.Name, errorM));
            }
            actionContext.Response = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.BadRequest,
                ReasonPhrase = strErrors.ToString(),
                Content = new StringContent(strErrors.ToString())
            };
        }
开发者ID:victorxata,项目名称:bartrade.rocks,代码行数:26,代码来源:ValidationAttribute.cs

示例3: Main

        static void Main( string[] args )
        {
            if ( args.Length != 1 )
            {
                return;
            }
            string fileName = args[ 0 ];
            StringBuilder fileContent = new StringBuilder( System.IO.File.ReadAllText( fileName ) );

            XmlDocument xdoc = new XmlDocument();
            xdoc.LoadXml( fileContent.ToString() );

            System.Xml.XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager( xdoc.NameTable );
            xmlnsManager.AddNamespace( "gpx", "http://www.topografix.com/GPX/1/0" );

            XmlNodeList timeNodes = xdoc.SelectNodes( "//gpx:time", xmlnsManager );
            foreach ( XmlNode timeNode in timeNodes )
            {
                string[] split1 = timeNode.InnerText.Split( 'T' );
                string[] splitDays = split1[ 0 ].Split( '-' );
                string[] splitHours = split1[ 1 ].Replace( "Z", "" ).Split( ':' );

                fileContent.Replace( timeNode.InnerText, new DateTime( int.Parse( splitDays[ 0 ] ), int.Parse( splitDays[ 1 ] ), int.Parse( splitDays[ 2 ] ),
                    int.Parse( splitHours[ 0 ] ), int.Parse( splitHours[ 1 ] ), int.Parse( splitHours[ 2 ] ) ).ToUniversalTime().ToString( "s" ) + "Z" );
            }

            System.IO.File.WriteAllText( fileName.Replace( ".gpx", "-fix.gpx" ), fileContent.ToString() );
        }
开发者ID:cbarbara,项目名称:RunKeeperGPXFixer,代码行数:28,代码来源:Program.cs

示例4: ParseLine

        /// <summary>
        /// Parses the specified <see cref="ISentence"/> object using a given <paramref name="parser"/>.
        /// </summary>
        /// <param name="sentence">The sentence to be parsed.</param>
        /// <param name="parser">The parser.</param>
        /// <param name="numParses">The number parses. Usually 1.</param>
        /// <returns>An array with the parsed results.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="sentence"/>
        /// or
        /// <paramref name="parser"/>
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">numParses</exception>
        /// <exception cref="System.InvalidOperationException">The sentence is not tokenized.</exception>
        public static Parse[] ParseLine(ISentence sentence, IParser parser, int numParses) {
            if (sentence == null)
                throw new ArgumentNullException("sentence");

            if (parser == null)
                throw new ArgumentNullException("parser");

            if (numParses < 0)
                throw new ArgumentOutOfRangeException("numParses");

            if (sentence.Tokens == null || sentence.Tokens.Count == 0)
                throw new InvalidOperationException("The sentence is not tokenized.");

            var sb = new StringBuilder(sentence.Length);
            for (var i = 0; i < sentence.Tokens.Count; i++) {
                sb.Append(sentence.Tokens[i].Lexeme).Append(' ');
            }
            sb.Remove(sb.Length - 1, 1);

            var start = 0;
            var p = new Parse(sb.ToString(), new Span(0, sb.Length), AbstractBottomUpParser.INC_NODE, 0, 0);

            for (var i = 0; i < sentence.Tokens.Count; i++) {
                p.Insert(
                    new Parse(
                        sb.ToString(), 
                        new Span(start, start + sentence.Tokens[i].Lexeme.Length),
                        AbstractBottomUpParser.TOK_NODE, 0, i));

                start += sentence.Tokens[i].Lexeme.Length + 1;
            }

            return numParses == 1 ? new[] { parser.Parse(p) } : parser.Parse(p, numParses);
        }
开发者ID:lovethisgame,项目名称:SharpNL,代码行数:48,代码来源:ParserTool.cs

示例5: FlushViewDataPool

		/// <summary>
		/// Flushes the view data pool.
		/// </summary>
		/// <returns></returns>
		public String FlushViewDataPool( ViewDataDictionary viewData ) {
			if ( WebConfigSettings.GetWebConfigAppSetting( "isFlushDataPool" ) != "true" )
				return "<!-- ViewData isn't configed by appsettings.config. -->";

			var sb = new StringBuilder();

			if ( viewData.Count == 0 ) {
				sb.Append( "<!-- ViewData flushly is configed by appsettings.config but viewData is empty. -->" );

				return sb.ToString();
			}

			sb.Append( "<script language=\"javascript\" type=\"text/javascript\">\r\n" );

			foreach ( var keyValuePair in viewData ) {
				sb.Append( "\t\tvar dataPool_" + keyValuePair.Key + " = " );
				sb.Append( JavaScriptConvert.SerializeObject( keyValuePair.Value ) + ";\r\n" );
			}

			sb.Remove( sb.Length - 2 , 2 );

			sb.Append( "\r\n\t</script>" );

			return sb.ToString();
		}
开发者ID:kisflying,项目名称:kion,代码行数:29,代码来源:ViewDataPool.cs

示例6: Compute

        public static double Compute(string expression)
        {
            var exp = expression.Replace(" ", "");
            var cons = new List<string>();
            var sb = new StringBuilder();
            foreach (char c in exp)
            {

                if (c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == ')')
                {
                    if (sb.Length > 0)
                    {
                        cons.Add(sb.ToString());
                        sb.Clear();
                    }
                    cons.Add(c.ToString());

                }
                else
                {
                    sb.Append(c);
                }
            }
            if (sb.Length > 0)
            {
                cons.Add(sb.ToString());
            }
            cons.ForEach(Console.WriteLine);
            return 0D;
        }
开发者ID:RainSong,项目名称:Sample,代码行数:30,代码来源:Computer1.cs

示例7: GetWords

    static void GetWords(string textLine)
    {
        StringBuilder word = new StringBuilder();
        foreach (char symbol in textLine)
        {
            if (char.IsLetter(symbol))
            {
                word.Append(symbol);
            }
            else
            {
                if (word.Length > 0)
                {
                    AddWordToHashSet(word.ToString());
                }

                word.Clear();
            }
        }

        if (word.Length > 0)
        {
            AddWordToHashSet(word.ToString());
        }
    }
开发者ID:vladislav-karamfilov,项目名称:TelerikAcademy,代码行数:25,代码来源:Words.cs

示例8: Update

        public int Update(Model.WebContentType1 model)
        {
            model.Replace4MySQL(); 
            StringBuilder sb = new StringBuilder();
            try
            {
                         WebContentType1 oldModel = GetModel(model);
                        if (model.content_status == 1 && oldModel.content_status != 1)//啟用
                        {
                            WebContentTypeSetupDao _setDao = new WebContentTypeSetupDao(_connStr);
                            WebContentTypeSetup smodel = new WebContentTypeSetup();
                            smodel.site_id = model.site_id;
                            smodel.page_id = model.page_id;
                            smodel.area_id = model.area_id;
                            smodel.web_content_type = "web_content_type1";
                            _setDao.UpdateLimitStatus(smodel);////當前已啟用的個數超過5筆時,使最舊的不啟用,
                        }
                       
                        sb.AppendFormat(@"update web_content_type1  set site_id='{0}',page_id='{1}',area_id='{2}',type_id='{3}',content_title='{4}',content_image='{5}',`content_default`='{6}',content_status='{7}',link_url='{8}',link_page='{9}',link_mode='{10}',update_on='{11}' where content_id={12}",
                            model.site_id, model.page_id, model.area_id, model.type_id, model.content_title, model.content_image, model.content_default, model.content_status, model.link_url, model.link_page, model.link_mode, CommonFunction.DateTimeToString(model.update_on), model.content_id);
                        return _access.execCommand(sb.ToString());
            }
            catch (Exception ex)
            {

                throw new Exception("WebContentType1Dao.Update-->" + ex.Message + sb.ToString(), ex);
            }
          
        }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:29,代码来源:WebContentType1Dao.cs

示例9: GetList

        public List<BannerNewsSiteQuery> GetList(BannerNewsSiteQuery bs, out int totalCount)
        {
            StringBuilder sqlfield = new StringBuilder();
            StringBuilder sqlwhere = new StringBuilder();
            StringBuilder sqlorderby = new StringBuilder();
            StringBuilder sql = new StringBuilder();
            sqlfield.AppendLine(@"SELECT	news_site_id,news_site_sort,news_site_status,news_site_mode,news_site_name,news_site_description,news_site_createdate,news_site_updatedate,news_site_ipfrom ");
            sqlfield.AppendLine(@" FROM	banner_news_site where news_site_status = 1 ");
            sql.Append(sqlfield);
            //sql.Append(sqlwhere);
            sqlorderby.AppendFormat(@" ORDER BY news_site_sort DESC ");
            sql.Append(sqlorderby);
            sql.AppendFormat(@" limit {0},{1};", bs.Start, bs.Limit);
            //int totalCount;
            totalCount = 0;
            try
            {
                if (bs.IsPage)
                {
                    DataTable dt = _access.getDataTable("select count(*) from banner_news_site where 1=1 " + sqlwhere);
                    totalCount = int.Parse(dt.Rows[0][0].ToString());
                }
                return _access.getDataTableForObj<BannerNewsSiteQuery>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("BannerNewsSiteDao-->GetList" + ex.Message + sql.ToString(), ex);
            }

        }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:30,代码来源:BannerNewsSiteDao.cs

示例10: TestServerToClient

        public void TestServerToClient()
        {
            IoAcceptor acceptor = new LoopbackAcceptor();
            IoConnector connector = new LoopbackConnector();

            acceptor.SessionOpened += (s, e) => e.Session.Write("B");
            acceptor.MessageSent += (s, e) => e.Session.Close(true);

            acceptor.Bind(new LoopbackEndPoint(1));

            StringBuilder actual = new StringBuilder();

            connector.MessageReceived += (s, e) => actual.Append(e.Message);
            connector.SessionClosed += (s, e) => actual.Append("C");
            connector.SessionOpened += (s, e) => actual.Append("A");

            IConnectFuture future = connector.Connect(new LoopbackEndPoint(1));

            future.Await();
            future.Session.CloseFuture.Await();
            acceptor.Unbind();
            acceptor.Dispose();
            connector.Dispose();

            // sessionClosed() might not be invoked yet
            // even if the connection is closed.
            while (actual.ToString().IndexOf("C") < 0)
            {
                Thread.Yield();
            }

            Assert.AreEqual("ABC", actual.ToString());
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:33,代码来源:LoopbackEventOrderTest.cs

示例11: Split

		public static string[] Split( string src, char delimiter, params char[] quotedelims )
		{
			ArrayList		strings = new ArrayList();
			StringBuilder	sb = new StringBuilder();
			ArrayList		ar = new ArrayList(quotedelims);
			char			quote_open = Char.MinValue;

			foreach (char c in src) 
			{
				if (c == delimiter && quote_open == Char.MinValue) 
				{
					strings.Add( sb.ToString() );
					sb.Remove( 0, sb.Length );
				}
					
				else if (ar.Contains(c)) 
				{
					if (quote_open == Char.MinValue)
						quote_open = c;
					else if (quote_open == c)
						quote_open = Char.MinValue;
					sb.Append(c);
				}
				else
					sb.Append( c );
			}

			if (sb.Length > 0)
				strings.Add( sb.ToString());

			return (string[])strings.ToArray(typeof(string));
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:32,代码来源:StringUtility.cs

示例12: GetInstallPathOfProduct

        /// <summary>
        /// Utility method for fetching the install path of a MSI installed product, given the name of that product.
        /// Adapted from: http://stackoverflow.com/questions/3526449/how-to-get-a-list-of-installed-software-products
        /// </summary>
        /// <param name="productName"></param>
        /// <returns></returns>
        public static IEnumerable<string> GetInstallPathOfProduct(string productName)
        {
            StringBuilder productCode = new StringBuilder(39);
            int index = 0;
            while (0 == MsiEnumProducts(index++, productCode))
            {
                Log.Debug("Found ProductCode: {0}", productCode.ToString());
                Int32 productNameLen = 512;
                StringBuilder foundProductName = new StringBuilder(productNameLen);

                MsiGetProductInfo(productCode.ToString(), "ProductName", foundProductName, ref productNameLen);
                Log.Debug("   Product name is: {0}", foundProductName.ToString());

                if (foundProductName.ToString().ToLower().Contains(productName.ToLower()))
                {
                    Log.Debug("   Product name matches: {0}", productName);

                    Int32 installPathLength = 1024;
                    StringBuilder installPath = new StringBuilder(installPathLength);

                    MsiGetProductInfo(productCode.ToString(), "InstallLocation", installPath, ref installPathLength);

                    Log.Debug("   Install path: {0}", installPath.ToString());

                    if (string.IsNullOrWhiteSpace(installPath.ToString()))
                        continue;

                    yield return installPath.ToString();
                }
            }
        }
开发者ID:ssali,项目名称:Context-Menu---Windows-Sync-,代码行数:37,代码来源:MsiUtils.cs

示例13: Execute

        public override string Execute(string[] args, Guid fromAgentID)
		{
            int channel = 0;
            int startIndex = 0;
            
            if (args.Length < 1)
            {
                return "usage: say (optional channel) whatever";
            }
            else if (args.Length > 1)
            {
                if (Int32.TryParse(args[0], out channel))
					startIndex = 1;
            }

            StringBuilder message = new StringBuilder();

			for (int i = startIndex; i < args.Length; i++)
            {
                message.Append(args[i]);
                if (i != args.Length - 1) message.Append(" ");
            }

			Client.Self.Chat(message.ToString(), channel, ChatType.Normal);

            return "Said " + message.ToString();
		}
开发者ID:RavenB,项目名称:gridsearch,代码行数:27,代码来源:SayCommand.cs

示例14: AddReviewBillContent

        /// <summary>
        /// 添加审稿单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddReviewBillContent(ReviewBillContentEntity model, DbTransaction trans = null)
        {
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append(" @CID");
            sqlCommandText.Append(", @JournalID");
            sqlCommandText.Append(", @ItemID");
            sqlCommandText.Append(", @ContentValue");
            sqlCommandText.Append(", @IsChecked");
            sqlCommandText.Append(", @AddUser");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.ReviewBillContent ({0},AddDate) VALUES ({1},getdate())", sqlCommandText.ToString().Replace("@", ""), sqlCommandText.ToString()));

            db.AddInParameter(cmd, "@ItemContentID", DbType.Int64, model.ItemContentID);
            db.AddInParameter(cmd, "@CID", DbType.Int64, model.CID);
            db.AddInParameter(cmd, "@JournalID", DbType.Int64, model.JournalID);
            db.AddInParameter(cmd, "@ItemID", DbType.AnsiString, model.ItemID);
            db.AddInParameter(cmd, "@ContentValue", DbType.AnsiString, model.ContentValue);
            db.AddInParameter(cmd, "@IsChecked", DbType.Boolean, model.IsChecked);
            db.AddInParameter(cmd, "@AddUser", DbType.Int64, model.AddUser);
            try
            {
                bool result = false;
                if (trans == null)
                    result = db.ExecuteNonQuery(cmd) > 0;
                else
                    result = db.ExecuteNonQuery(cmd, trans) > 0;
                if (!result)
                    throw new Exception("新增审稿单失败!");
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:zhanglc8801,项目名称:WKT2015,代码行数:40,代码来源:ReviewBillContentDataAccess.cs

示例15: GetNextCommand

        public string GetNextCommand()
        {
            //try
            //{
                StringBuilder builder = new StringBuilder();
                byte[] b = new byte[1];

                while (this.Receive(b) == 1)
                {
                    string c = ASCIIEncoding.ASCII.GetString(b);

                    builder.Append(c);

                    if (builder.ToString().Contains(CommandSeperator))
                    {
                        return builder.ToString();
                    }
                }
            //}
            //catch (Exception e)
            //{
            //    Close();
            //}

            return null;
        }
开发者ID:netngn,项目名称:MailDeluxe,代码行数:26,代码来源:SimpleSocket.cs


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