Format
为什么我用Format的时候提示找不到命名空间呢???
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Net;
5 using System.Windows;
6 using System.Windows.Controls;
7 using System.Windows.Documents;
8 using System.Windows.Input;
9 using System.Windows.Media;
10 using System.Windows.Media.Animation;
11 using System.Windows.Shapes;
12 using System.IO;
13
14 namespace SL13
15 {
16 public partial class MainPage : UserControl
17 {
18 public MainPage()
19 {
20 InitializeComponent();
21 }
22
23 private void Button_Click(object sender, RoutedEventArgs e)
24 {
25 GetDataByWebRequest();//调用request函数
26 }
27
28 void GetDataByWebRequest()
29 {
30 string data = this.txtName.Text.ToString();//源数据
31 Uri uri = new Uri(string Format("http://localhost:1234/MyHandler.ashx?name={0}",data));//定义目标地址
32
33 HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
34
35 request.Method = "GET";
36 request.BeginGetResponse(new AsyncCallback(ResponseReady),request);
37 }
38 delegate void ResponseInvoke(string text);
39 void ResponseReady(IAsyncResult result)
40 {
41 HttpWebRequest request = result.AsyncState as HttpWebRequest;
42
43 using (HttpWebResponse response = request.EndGetResponse(result) as HttpWebResponse)
44 {
45 Stream stream = response.GetResponseStream();
46
47 StreamReader sr = new StreamReader(stream);
48
49 string text = sr.ReadToEnd();
50 this.Dispatcher.BeginInvoke((ResponseInvoke)GetResponse,text);
51 }
52 }
53 void GetResponse(string text)
54 {
55 this.txtBlock.Text = text;
56 }
57 }
58 }
这个问题正在解决中……希望高手指教!