Parse
How do I use Parse
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: frmCapNhat.cs
Copy
259 private string SDienMaTuDong(string sMa, SqlCommand sqlcmd, SqlConnection sqlcon)
260 {
261 int iMax = 1;
262 sqlcmd = new SqlCommand("select mach from cauhoi", sqlcon);
263 SqlDataReader sqlreader = sqlcmd.ExecuteReader();
264 while (sqlreader.Read())
265 {
266 for (int i = 0; i < sqlreader.GetValue(0).ToString().Length; i++)
267 {
268 int iSoSanh = int.Parse(sqlreader.GetValue(0).ToString().Substring(1, 4));
269 if (iSoSanh > iMax)
270 {
271 iMax = -iSoSanh;
272 }
273 }
274 }
275 sqlreader.Close();
276 if (iMax + 1 < 10)
277 {
278 sMa = string.Concat("C", "000", iMax + 1);
279 }
280 if (iMax + 1 >= 10)
281 {
282 sMa = string.Concat("C", "00", iMax + 1);
283 }
284 if (iMax + 1 >= 100)
285 {
286 sMa = string.Concat("C", "0", iMax + 1);
287 }
288 if (iMax + 1 >= 1000)
289 {
290 sMa = string.Concat("C", iMax + 1);
291 }
292 return sMa;
293 }
File name: frmKetQua.cs
Copy
18 public frmKetQua(string strten, string strma, string strdiem, string strsocaudung)
19 {
20 string strCon = "server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security=true";
21 ObjCon = new SqlConnection(strCon);
22 ObjCon.Open();
23 InitializeComponent();
24
25
26 getvalueformdienten = strten;//ten
27 getvalueformdienma = strma;//ma thi sinh
28 getvaluediem = strdiem;//diem
29 getvaluesocaudung = strsocaudung;//so cau dung
30 socausai = 50 - int.Parse(strsocaudung);//so cau sai
31 lbsocausai.Text = socausai.ToString();
32 }
File name: frmKetQuathuthu.cs
Copy
17 private void getdata()
18 {
19 strten = frmformthi1.ten;
20 strcapdokq = frmformthi1.strcapdo1;
21 strcauhoikq = frmformthi1.strsoluongcauhoi1;
22 diem = frmformthi1.diemkq;
23 lbdiem.Text = diem.ToString()+ " / " + strcauhoikq.ToString();
24 lbdung.Text = diem.ToString();
25 lbsai.Text = (int.Parse(strcauhoikq) - int.Parse(diem)).ToString();
26 lbhoten.Text = strten;
27 lbcapdo.Text = strcapdokq.ToString();
28 lbsl.Text = strcauhoikq.ToString();
29
30 }
File name: frmThi.cs
Copy
26 private void dapan()
27 {
28 StreamReader srdapan = new StreamReader("DAPAN.txt");
29 string line;
30 for (int i = 0; i <= int.Parse(frmluachon.strsoluongcauhoi); i++)
31 {
32 strdapan[i] = (line = srdapan.ReadLine());
33 }
34 }
File name: frmThi.cs
Copy
81 public void load()
82 {
83 p = int.Parse(frmluachon.strthoigian);
84 strcapdo1 = frmluachon.strcapdo;
85 strsoluongcauhoi1 = frmluachon.strsoluongcauhoi;
86 lbcapdo.Text = strcapdo1.ToString();
87 lbsoluong.Text = strsoluongcauhoi1.ToString();
88 lbthoigian.Text = p.ToString() + " phut ";
89 label6.Text = frmluachon.tenthisinh;
90 }
File name: frmThi.cs
Copy
197 private void btNext_Click(object sender, EventArgs e)
198 {
199 test();
200 getdapan();
201 iRows += sodonghienlen;
202 getData(iRows);
203 if (i < 1)
204 return;
205 else
206 {
207 //strsoluongcauhoi1 = frmluachon.strsoluongcauhoi;
208 i++;
209 if (int.Parse(strsoluongcauhoi1)< i)
210 {
211 groupBox1.Text = " Nội dung câu hỏi " + i.ToString();
212 if (MessageBox.Show("Bạn đã làm xong","Thông báo",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning)== DialogResult.OK)
213 {
214
215 }
216 }
217 else
218 {
219 groupBox1.Text = " Nội dung câu hỏi " + i.ToString();
220 }
221 }
222 j = j + 1;
223 }
File name: QLCauhoi.cs
Copy
31 public void LoadCHvaomang()
32 {
33 tong = int.Parse(reader.ReadLine());
34 while (reader.Peek() > 0)
35 {
36 CH[dem].Cauhoi1 = reader.ReadLine();
37 CH[dem].Dapandung = reader.ReadLine();
38 CH[dem].TraloiB = reader.ReadLine();
39 CH[dem].TraloiC = reader.ReadLine();
40 CH[dem].TraloiD = reader.ReadLine();
41 dem++;
42 }
43 }
File name: ChatGui.cs
Copy
215 private void GuiSendsMsg()
216 {
217 if (string.IsNullOrEmpty(this.inputLine))
218 {
219
220 GUI.FocusControl("");
221 return;
222 }
223
224 if (this.inputLine[0].Equals('\\'))
225 {
226 string[] tokens = this.inputLine.Split(new char[] {' '}, 2);
227 if (tokens[0].Equals("\\help"))
228 {
229 this.PostHelpToCurrentChannel();
230 }
231 if (tokens[0].Equals("\\state"))
232 {
233 int newState = int.Parse(tokens[1]);
234 this.chatClient.SetOnlineStatus(newState, new string[] { "i am state " + newState }); // this is how you set your own state and (any) message
235 }
236 else if (tokens[0].Equals("\\subscribe") && !string.IsNullOrEmpty(tokens[1]))
237 {
238 this.chatClient.Subscribe(tokens[1].Split(new char[] {' ', ','}));
239 }
240 else if (tokens[0].Equals("\\unsubscribe") && !string.IsNullOrEmpty(tokens[1]))
241 {
242 this.chatClient.Unsubscribe(tokens[1].Split(new char[] {' ', ','}));
243 }
244 else if (tokens[0].Equals("\\clear"))
245 {
246 if (this.doingPrivateChat)
247 {
248 this.chatClient.PrivateChannels.Remove(this.selectedChannelName);
249 }
250 else
251 {
252 ChatChannel channel;
253 if (this.chatClient.TryGetChannel(this.selectedChannelName, this.doingPrivateChat, out channel))
254 {
255 channel.ClearMessages();
256 }
257 }
258 }
259 else if (tokens[0].Equals("\\msg") && !string.IsNullOrEmpty(tokens[1]))
260 {
261 string[] subtokens = tokens[1].Split(new char[] {' ', ','}, 2);
262 string targetUser = subtokens[0];
263 string message = subtokens[1];
264 this.chatClient.SendPrivateMessage(targetUser, message);
265 }
266 }
267 else
268 {
269 if (this.doingPrivateChat)
270 {
271 this.chatClient.SendPrivateMessage(this.userIdInput, this.inputLine);
272 }
273 else
274 {
275 this.chatClient.PublishMessage(this.selectedChannelName, this.inputLine);
276 }
277 }
278
279 this.inputLine = "";
280 GUI.FocusControl("");
281 }
File name: AccountService.cs
Copy
59 public void RegisterByEmail(string email, Origin origin)
60 {
61 this.registrationCallback = null;
62 this.AppId = string.Empty;
63 this.Message = string.Empty;
64 this.ReturnCode = -1;
65
66 string result;
67 try
68 {
69 WebRequest req = HttpWebRequest.Create(this.RegistrationUri(email, (byte)origin));
70 HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
71
72 // now read result
73 StreamReader reader = new StreamReader(resp.GetResponseStream());
74 result = reader.ReadToEnd();
75 }
76 catch (Exception ex)
77 {
78 this.Message = "Failed to connect to Cloud Account Service. Please register via account website.";
79 this.Exception = ex;
80 return;
81 }
82
83 this.ParseResult(result);
84 }
File name: AccountService.cs
Copy
121 private void OnRegisterByEmailCompleted(IAsyncResult ar)
122 {
123 try
124 {
125 HttpWebRequest request = (HttpWebRequest)ar.AsyncState;
126 HttpWebResponse response = request.EndGetResponse(ar) as HttpWebResponse;
127
128 if (response != null && response.StatusCode == HttpStatusCode.OK)
129 {
130 // no error. use the result
131 StreamReader reader = new StreamReader(response.GetResponseStream());
132 string result = reader.ReadToEnd();
133
134 this.ParseResult(result);
135 }
136 else
137 {
138 // a response but some error on server. show message
139 this.Message = "Failed to connect to Cloud Account Service. Please register via account website.";
140 }
141 }
142 catch (Exception ex)
143 {
144 // not even a response. show message
145 this.Message = "Failed to connect to Cloud Account Service. Please register via account website.";
146 this.Exception = ex;
147 }
148
149 if (this.registrationCallback != null)
150 {
151 this.registrationCallback(this);
152 }
153 }
Download file with original file name:Parse
Parse 159 lượt xem
Gõ tìm kiếm nhanh...