Chuyển Random sang string trong c#

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
 

taplamhacker

♥ Thanh Trâm ♥
Reply: c#

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à
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");
+
Mã:
[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]
cái này đúng và luôn trả về String có lẽ bị lỗi nào khác chăng
 
Reply: c#

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");
+
Mã:
[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]
cái này đúng và luôn trả về String có lẽ bị lỗi nào khác chăng

j mà nó cứ báo lỗi không thể convert từ windows.ui.Random to String
 

taplamhacker

♥ Thanh Trâm ♥
Reply: c#

j mà nó cứ báo lỗi không thể convert từ windows.ui.Random to String
đây nha bạn mình vừa test thử sài ok con tê tê luôn
Mã:
Random a = new Random();
int b = a.Next(1, 1000);
abcd.Text = "";
abcd.Inlines.Add(b.ToString());
nếu vẫn báo lỗi thì bạn bị lỗi chổ nào khác rồi
phải xem code bạn add như nào mới biết dc
 
Top