当前位置: 首页>>代码示例>>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;未经允许,请勿转载。