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


C# StringReader.ToString方法代碼示例

本文整理匯總了C#中System.IO.StringReader.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# StringReader.ToString方法的具體用法?C# StringReader.ToString怎麽用?C# StringReader.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.StringReader的用法示例。


在下文中一共展示了StringReader.ToString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PostXML

        /// <summary>
        /// Take a URL and a string that is XML and post it, return the response
        /// </summary>
        /// <param name="url"></param>
        /// <param name="xmlToConvert"></param>
        /// <returns></returns>
        public static string PostXML(string url, string xmlToConvert)
        {
            // Configure HTTP Request
            HttpWebRequest httpRequest = WebRequest.Create(url) as HttpWebRequest;
            httpRequest.Method = "POST";

            // Prepare correct encoding for XML serialization
            UTF8Encoding encoding = new UTF8Encoding();

            // Use Xml property to obtain serialized XML data
            // Convert into bytes using encoding specified above and
            // get length
            byte[] bodyBytes = encoding.GetBytes(xmlToConvert);
            httpRequest.ContentLength = bodyBytes.Length;

            try
            {
                // Get HTTP Request stream for putting XML data into
                Stream httpRequestBodyStream = httpRequest.GetRequestStream();

                // Fill stream with serialized XML data
                httpRequestBodyStream.Write(bodyBytes, 0, bodyBytes.Length);
                httpRequestBodyStream.Close();

                // Get HTTP Response
                HttpWebResponse httpResponse = httpRequest.GetResponse() as HttpWebResponse;
                StreamReader httpResponseStream =
                    new StreamReader(httpResponse.GetResponseStream(),
                  System.Text.Encoding.ASCII);

                // Extract XML from response
                string httpResponseBody = httpResponseStream.ReadToEnd();
                httpResponseStream.Close();

                if (string.IsNullOrEmpty(httpResponseBody)) return string.Empty;

                // Ignore everything that isn't XML by removing headers
                httpResponseBody = httpResponseBody.Substring(httpResponseBody.IndexOf("<?xml"));

                //   Deserialize XML into DataCashResponse
                StringReader responseReader = new StringReader(httpResponseBody);
                return responseReader.ToString();
            }
            catch (Exception ex)
            {
                Utilities.LogError(ex);
                return string.Empty;
            }
        }
開發者ID:pakoito,項目名稱:web,代碼行數:55,代碼來源:XMLUtil.cs

示例2: Main


//.........這裏部分代碼省略.........
                            continue;
                        }
                    }

            /*        if (line1[j] == '@' && j + 1 < line1.Length && line1[j + 1] == '\"')
                    {
                        inString = true;
                        inMultilineString = true;
                        j++;
                        code.Append("@\"");
                        clear = clear + ("@\"");
                        continue;
                    }
            */
                    if (line1[j] == '\"')
                    {
                        inString = true;
                    }

                    if (line1[j] == '\'')
                    {
                        inString = true;
                        inSingleQuotedString = true;
                    }

                    code.Append(line1[j]);
                   // string line1 = Regex.Replace(line[j], @"[//]\s*([^"">]+)\s*[\n]", "");
                    clear = clear + (line1[j]);
                }

                if (!inMultiLineComment) code.AppendLine();
            } while (!line.Equals("?>"));

            StringReader sr = new StringReader(code.ToString());
            string lineToPrint = null;
            while ((lineToPrint = sr.ReadLine()) != null)
            {
                if (!string.IsNullOrWhiteSpace(lineToPrint))
                {
              //      Console.WriteLine(lineToPrint);
                }
            }
            //Console.WriteLine(sr);
            string newString = sr.ToString();
            string[] arr=new string[10000];
            //Console.WriteLine(clear);
            //Console.WriteLine(clear.IndexOf("$"));
            int index = -1;
              //  Console.WriteLine(newString.IndexOf("f"));
            //string dol = @"$";

            //Console.WriteLine(newString);
               // Console.WriteLine("index = {0}", index);
            int k=-1;
            int l;
            do
            {
                k++;
                index = clear.IndexOf("$", index+1);
                l = 10000000;
                if (clear.IndexOf(" ", index + 1) > -1)
                {
                    l = clear.IndexOf(" ", index + 1);
                }
                int m = clear.IndexOf("=", index + 1);
                if (m<l && m>-1) l=m;
開發者ID:mitev-web,項目名稱:csharp-fundamentals,代碼行數:67,代碼來源:Problem+1+PHP+Variables.cs


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