Re: ChartAt(index) in C#?
Try this:
Code:
string str = "hello world";
Console.WriteLine( str[0] ); //returns "h";
Console.WriteLine( str[2] ); //returns "l";
Re: ChartAt(index) in C#?
Great! That works perfect. Thanks DeadEyes. :)
Re: ChartAt(index) in C#?
I am actually migrating from VB.NET to C#.NET. So I am new to C# commands. I am trying C# in small methods to familiarize myself with C#.
For instance..
Code:
Private Sub RandomPasswords()
Dim i%
Dim pass As String
Dim passChar As Char
For i = 1 To 8
Randomize()
If Int(Rnd() * 2) = 0 Then
passChar = Chr((Rnd() * (57 - 48)) + 48)
Else
passChar = Chr((Rnd() * (90 - 65)) + 65)
End If
pass &= passChar
Next
txtPassword.Text = pass
txtPassword.PasswordChar = ""
End Sub
I am trying to re-write the above using C#. But I can't find Randomize() or Rnd() or similar statements/funtions in C#. Can you please give me a hand on this too? Much appreciated. :)
Re: ChartAt(index) in C#?
There is a Random Class
Code:
const int MAX =10;
Random r = new Random();
Console.WriteLine(r.Next(MAX).ToString());
Console.WriteLine(r.Next(MAX).ToString());
Console.WriteLine(r.Next(MAX).ToString());