當前位置: 首頁>>代碼示例>>C#>>正文


C# System.StringBuilder類代碼示例

本文整理匯總了C#中System.StringBuilder的典型用法代碼示例。如果您正苦於以下問題:C# StringBuilder類的具體用法?C# StringBuilder怎麽用?C# StringBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StringBuilder類屬於System命名空間,在下文中一共展示了StringBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: decodeMiddle

        protected internal override int decodeMiddle(BitArray row, int[] startRange, StringBuilder result)
        {
            int[] counters = decodeMiddleCounters;
            counters[0] = 0;
            counters[1] = 0;
            counters[2] = 0;
            counters[3] = 0;
            int end = row.Size;
            int rowOffset = startRange[1];

            for (int x = 0; x < 4 && rowOffset < end; x++)
            {
                int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
                result.Append(Int32Extend.ToChar(CharExtend.ToInt32('0') + bestMatch));
                for (int i = 0; i < counters.Length; i++)
                {
                    rowOffset += counters[i];
                }
            }

            int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN);
            rowOffset = middleRange[1];

            for (int x = 0; x < 4 && rowOffset < end; x++)
            {
                int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
                result.Append(Int32Extend.ToChar(CharExtend.ToInt32('0') + bestMatch));
                for (int i = 0; i < counters.Length; i++)
                {
                    rowOffset += counters[i];
                }
            }

            return rowOffset;
        }
開發者ID:tomcat1234,項目名稱:WebQRReader,代碼行數:35,代碼來源:EAN8Reader.cs

示例2: ToGEOJson

        public static string ToGEOJson(this DataTable dt, string latColumn, string lngColumn)
        {
            StringBuilder result = new StringBuilder();
            StringBuilder line;

            foreach (DataRow r in dt.Rows)
            {
                line = new StringBuilder();

                foreach (DataColumn col in dt.Columns)
                {
                    if (col.ColumnName != latColumn && col.ColumnName != lngColumn)
                    {
                        string cValue = r[col].ToString();
                        line.Append(",\"" + col.ColumnName + "\":\"" + cValue.Replace("\"","\\\"") + "\"");
                    }

                }

                result.Append(
                    ",{\"type\":\"Feature\",\"geometry\": {\"type\":\"Point\", \"coordinates\": [" + r[lngColumn].ToString() + "," + r[latColumn].ToString() + "]},\"properties\":{" +
                    line.ToString().Substring(1) + "}}");

            }

            string geojson = "{\"type\": \"FeatureCollection\",\"features\": [" +
                result.ToString().Substring(1) + "]}";

            return geojson;
        }
開發者ID:Kartessian,項目名稱:JSON-Sharp,代碼行數:30,代碼來源:extensions.cs

示例3: ConvertQueryHashtable

        /// <summary>
        /// Converts the query string to an string.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="separator"></param>
        /// <param name="nameValueSeparator"></param>
        /// <returns></returns>
        public string ConvertQueryHashtable(Hashtable data, string separator, string nameValueSeparator)
        {
            // QueryString
            StringBuilder queryString = new StringBuilder();

            foreach ( DictionaryEntry de in data )
            {
                ArrayList itemValues = (ArrayList)de.Value;
                string key = (string)de.Key;

                if ( nameValueSeparator.Length == 0 )
                {
                    //queryString.Append(key);
                    queryString.Append(separator);
                    queryString.Append(itemValues[0]);
                }
                else
                {
                    foreach ( string s in itemValues )
                    {
                        queryString.Append(key);
                        queryString.Append(nameValueSeparator);
                        queryString.Append(s);
                        queryString.Append(separator);
                    }
                }
            }

            return queryString.ToString();
        }
開發者ID:molekilla,項目名稱:Ecyware_GreenBlue_Inspector,代碼行數:37,代碼來源:UriParser.cs

示例4: GetUsage

 public string GetUsage()
 {
     var usage = new StringBuilder();
     usage.AppendLine("Process Scheduler");
     usage.AppendLine("-i, --input [filename]");
     return usage.ToString();
 }
開發者ID:silverfoxy,項目名稱:ProcessScheduler,代碼行數:7,代碼來源:Options.cs

示例5: ReverseString

 public static string ReverseString(string s)
 {
     StringBuilder sb = new StringBuilder();
     for(int i = s.Length; i > 0; i--){
     sb.Append(s[i-1]);
     }
 }
開發者ID:franvarney,項目名稱:cs-study,代碼行數:7,代碼來源:Solution.cs

示例6: DisplayData

		public void DisplayData(object[] data)
		{
			StringBuilder sb = new StringBuilder();
			sb.Append(view.uiHeaderTemplateHolder.InnerHTML.Unescape());
			if (data != null)
			{
				string currentGroupByFieldValue = "";
				for (int i = 0; i < data.Length; i++)
				{
					Dictionary<object, object> dataItem = (Dictionary<object, object>)data[i];
					if (GroupByField != "")
					{
						if (currentGroupByFieldValue != (string) dataItem[GroupByField])
						{
							currentGroupByFieldValue = (string) dataItem[GroupByField];
							sb.Append("<div class='ClientSideRepeaterGroupHeader'>" + currentGroupByFieldValue + "</div>");
						}
					}
					sb.Append(this.view.uiItemTemplate.Render(dataItem));
					if (i + 1 < data.Length)
					{
						sb.Append(view.uiBetweenTemplateHolder.InnerHTML.Unescape());
					}
				}
			}
			sb.Append(view.uiFooterTemplateHolder.InnerHTML.Unescape());
			view.uiContent.InnerHTML = sb.ToString();
		}
開發者ID:davelondon,項目名稱:dontstayin,代碼行數:28,代碼來源:Repeater.Controller.cs

示例7: SerializeForm

        internal static string SerializeForm(FormElement form) {
            DOMElement[] formElements = form.Elements;
            StringBuilder formBody = new StringBuilder();

            int count = formElements.Length;
            for (int i = 0; i < count; i++) {
                DOMElement element = formElements[i];
                string name = (string)Type.GetField(element, "name");
                if (name == null || name.Length == 0) {
                    continue;
                }

                string tagName = element.TagName.ToUpperCase();

                if (tagName == "INPUT") {
                    InputElement inputElement = (InputElement)element;
                    string type = inputElement.Type;
                    if ((type == "text") ||
                        (type == "password") ||
                        (type == "hidden") ||
                        (((type == "checkbox") || (type == "radio")) && (bool)Type.GetField(element, "checked"))) {

                        formBody.Append(name.EncodeURIComponent());
                        formBody.Append("=");
                        formBody.Append(inputElement.Value.EncodeURIComponent());
                        formBody.Append("&");
                    }
                }
                else if (tagName == "SELECT") {
                    SelectElement selectElement = (SelectElement)element;
                    int optionCount = selectElement.Options.Length;
                    for (int j = 0; j < optionCount; j++) {
                        OptionElement optionElement = (OptionElement)selectElement.Options[j];
                        if (optionElement.Selected) {
                            formBody.Append(name.EncodeURIComponent());
                            formBody.Append("=");
                            formBody.Append(optionElement.Value.EncodeURIComponent());
                            formBody.Append("&");
                        }
                    }
                }
                else if (tagName == "TEXTAREA") {
                    formBody.Append(name.EncodeURIComponent());
                    formBody.Append("=");
                    formBody.Append(((string)Type.GetField(element, "value")).EncodeURIComponent());
                    formBody.Append("&");
                }
            }

            // additional input represents the submit button or image that was clicked
            string additionalInput = (string)Type.GetField(form, "_additionalInput");
            if (additionalInput != null) {
                formBody.Append(additionalInput);
                formBody.Append("&");
            }

            return formBody.ToString();
        }
開發者ID:jesshaw,項目名稱:ASP.NET-Mvc-3,代碼行數:58,代碼來源:MvcHelpers.cs

示例8: GenerateSharedFolderPath

        private static string GenerateSharedFolderPath(string sourcePath)
        {
            string fileName = System.IO.Path.GetFileName(sourcePath);
            System.StringBuilder destinationPath = new System.StringBuilder(SharedFolderPath);
            destinationPath.Replace("{CopyTo:SharedFolder}", System.Configuration.ConfigurationManager.AppSettings["SharedFolder"]);
            destinationPath.Replace("{CopyTo:FileName}", fileName);

            return destinationPath.ToString();
        }
開發者ID:priestofpsi,項目名稱:theDiary-Common-Framework,代碼行數:9,代碼來源:Program.cs

示例9: ToString

 /// <summary>
 ///   Returns a <see cref="T:System.String" /> that represents the current <see cref="T:System.Object" />.
 /// </summary>
 /// <param name="baseUrl"> The base URL. </param>
 /// <returns> A <see cref="T:System.String" /> that represents the current <see cref="T:System.Object" /> . </returns>
 public virtual String ToString(String baseUrl)
 {
     var sb = new StringBuilder();
     foreach (var pair in _dictionary)
     {
         if (sb.Length > 0) sb.Append("&");
         sb.AppendFormat("{0}={1}", pair.Key, pair.Value);
     }
     return baseUrl.IsNotNullOrEmpty() ? String.Concat(baseUrl, "?", sb.ToString()) : sb.ToString();
 }
開發者ID:erashid,項目名稱:Extensions,代碼行數:15,代碼來源:UriQueryString.cs

示例10: UnifiedContextCreator

        public UnifiedContextCreator()
            : base()
        {
            this.classSource = new System.StringBuilder(UnifiedContextCreator.GetTemplate("UnifiedContext"));
            this.dbSets = new Dictionary<Type, string>();
            this.namespaces = new List<string>();

            this.referencedAssemblies = new List<string>();
            this.AddAssemblyReference(typeof(UnifiedContextCreator).Assembly);
        }
開發者ID:priestofpsi,項目名稱:theDiary-Common-Framework,代碼行數:10,代碼來源:UnifiedContextCreator.cs

示例11: AreaRegistrationCreator

 public AreaRegistrationCreator(IHostedApplication hostedApplication)
     : base()
 {
     this.classSource = new System.StringBuilder(AreaRegistrationCreator.GetTemplate("AreaRegistration"));
     this.dbSets = new Dictionary<Type, string>();
     this.namespaces = new List<string>();
     this.hostedApplication = hostedApplication;
     this.referencedAssemblies = new List<string>();
     this.AddAssemblyReference(typeof(AreaRegistrationCreator).Assembly);
 }
開發者ID:priestofpsi,項目名稱:theDiary-Common-Framework,代碼行數:10,代碼來源:AreaRegistrationCreator.cs

示例12: Script

        public ActionResult Script()
        {
            StringBuilder sb = new StringBuilder();
            Dictionary<string, object> clientValidationRules = this.GetClientValidationRules();

            sb.AppendLine("(function () {");
            sb.AppendLine(String.Format("\tMilkshake.clientValidationRules = {0};", JsonConvert.SerializeObject(clientValidationRules)));
            sb.AppendLine("})();");

            return Content(sb.ToString(), "text/javascript");
        }
開發者ID:martinnormark,項目名稱:aspnet-mvc-client-validation-bridge,代碼行數:11,代碼來源:ClientValidationRulesController.cs

示例13: BytesToHexString

        /// <summary>
        /// Converts an array of bytes to a hex string representation.
        /// </summary>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static string BytesToHexString(this byte[] bytes)
        {
            var builder = new StringBuilder();

            foreach (byte b in bytes)
            {
                builder.Append(StringUtility.Format("{0:X}", b));
            }

            return builder.ToString();
        }
開發者ID:ukkiwisurfer,項目名稱:Framework.Embedded,代碼行數:16,代碼來源:ByteArrayExtensions.cs

示例14: GenerateSigningArguments

        private static string GenerateSigningArguments(string fileName)
        {
            string certificatePath = GetSigningCertificatePath();
            System.StringBuilder returnValue = new System.StringBuilder(SigningProcessArgumentsFormat);
            returnValue.Replace("'{Signing:CertificatePath}'", certificatePath);
            returnValue.Replace("'{Signing:File}'", fileName);
            returnValue.Replace("{Signing:SigningPassword}", System.Configuration.ConfigurationManager.AppSettings["SigningPassword"]);
            returnValue.Replace("{Signing:SigningTimestampUrl}", System.Configuration.ConfigurationManager.AppSettings["SigningTimestampUrl"]);

            return returnValue.ToString();
        }
開發者ID:priestofpsi,項目名稱:theDiary-Common-Framework,代碼行數:11,代碼來源:Program.cs

示例15: maybeAppend1

 public static void maybeAppend1(String value_Renamed, StringBuilder result)
 {
     if (value_Renamed != null && value_Renamed.Length > 0)
     {
         // Don't add a newline before the first value
         if (result.ToString().Length > 0)
         {
             result.Append('\n');
         }
         result.Append(value_Renamed);
     }
 }
開發者ID:tomcat1234,項目名稱:WebQRReader,代碼行數:12,代碼來源:ParsedResult.cs


注:本文中的System.StringBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。