T
Tony Johansson
Hi
I just want your opinion about using the feature to add "" to make it a
string.
So is it bad and more unreadable to use the "" feature to make it a string ?
In example #1 below I use the feature to add "" to make it a string but
in #2 I use the standard method to use the ToString to it a string
static void Main(string[] args)
{
string letters = "ABCD";
Random random = new Random();
string letterCode;
#1 letterCode = "" + letters[random.Next(0,4)] +
letters[random.Next(0,4)];
#2 letterCode = letters[random.Next(0,4)].ToString() +
letters[random.Next(0,4)].ToString();
}
//Tony
I just want your opinion about using the feature to add "" to make it a
string.
So is it bad and more unreadable to use the "" feature to make it a string ?
In example #1 below I use the feature to add "" to make it a string but
in #2 I use the standard method to use the ToString to it a string
static void Main(string[] args)
{
string letters = "ABCD";
Random random = new Random();
string letterCode;
#1 letterCode = "" + letters[random.Next(0,4)] +
letters[random.Next(0,4)];
#2 letterCode = letters[random.Next(0,4)].ToString() +
letters[random.Next(0,4)].ToString();
}
//Tony