bạn nào bít cách chuyển từ Random sang string trong c# thì chỉ mình với....mình thử đủ cách trên google ùi nó cứ báo lỗi không thể covert j j đó...bạn nào bít giúp mình với thanks
cái này mình thử ùi mà truyền vào textBlock.text nóa cứ báo lỗi hông hàRandom rd = new Random();
string temp = rd.Next(1000, 9999).ToString();
bạn gửi code lên đây mình xem thử dc kcái này mình thử ùi mà truyền vào textBlock.text nóa cứ báo lỗi hông hà
abcd.Text = ""; // textblock của mình
abcd.Inlines.Add("abcd");
[COLOR=#4ec9b0][FONT=Arial]Random[/FONT][/COLOR][COLOR=#000000][FONT=Arial] rd [/FONT][/COLOR][COLOR=#b4b4b4][FONT=Arial]=[/FONT][/COLOR][COLOR=#000000][FONT=Arial] [/FONT][/COLOR][COLOR=#569cd6][FONT=Arial]new[/FONT][/COLOR][COLOR=#000000][FONT=Arial] [/FONT][/COLOR][COLOR=#4ec9b0][FONT=Arial]Random[/FONT][/COLOR][COLOR=#000000][FONT=Arial]();[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]string temp [/FONT][/COLOR][COLOR=#b4b4b4][FONT=Arial]=[/FONT][/COLOR][COLOR=#000000][FONT=Arial] rd[/FONT][/COLOR][COLOR=#b4b4b4][FONT=Arial].[/FONT][/COLOR][COLOR=#000000][FONT=Arial]Next([/FONT][/COLOR][COLOR=#b5cea8][FONT=Arial]1000[/FONT][/COLOR][COLOR=#000000][FONT=Arial], [/FONT][/COLOR][COLOR=#b5cea8][FONT=Arial]9999[/FONT][/COLOR][COLOR=#000000][FONT=Arial])[/FONT][/COLOR][COLOR=#b4b4b4][FONT=Arial].[/FONT][/COLOR][COLOR=#000000][FONT=Arial]ToString();[/FONT][/COLOR]
bạn gửi code lên đây mình xem thử dc k
bạn xem thử nó báo lỗi gì
+Mã:abcd.Text = ""; // textblock của mình abcd.Inlines.Add("abcd");
cái này đúng và luôn trả về String có lẽ bị lỗi nào khác chăngMã:[COLOR=#4ec9b0][FONT=Arial]Random[/FONT][/COLOR][COLOR=#000000][FONT=Arial] rd [/FONT][/COLOR][COLOR=#b4b4b4][FONT=Arial]=[/FONT][/COLOR][COLOR=#569cd6][FONT=Arial]new[/FONT][/COLOR][COLOR=#4ec9b0][FONT=Arial]Random[/FONT][/COLOR][COLOR=#000000][FONT=Arial]();[/FONT][/COLOR] [COLOR=#000000][FONT=Arial]string temp [/FONT][/COLOR][COLOR=#b4b4b4][FONT=Arial]=[/FONT][/COLOR][COLOR=#000000][FONT=Arial] rd[/FONT][/COLOR][COLOR=#b4b4b4][FONT=Arial].[/FONT][/COLOR][COLOR=#000000][FONT=Arial]Next([/FONT][/COLOR][COLOR=#b5cea8][FONT=Arial]1000[/FONT][/COLOR][COLOR=#000000][FONT=Arial], [/FONT][/COLOR][COLOR=#b5cea8][FONT=Arial]9999[/FONT][/COLOR][COLOR=#000000][FONT=Arial])[/FONT][/COLOR][COLOR=#b4b4b4][FONT=Arial].[/FONT][/COLOR][COLOR=#000000][FONT=Arial]ToString();[/FONT][/COLOR]
đây nha bạn mình vừa test thử sài ok con tê tê luônj mà nó cứ báo lỗi không thể convert từ windows.ui.Random to String
Random a = new Random();
int b = a.Next(1, 1000);
abcd.Text = "";
abcd.Inlines.Add(b.ToString());