I am comparing to arrays to see which value (char) in the array is bigger. It worked fine until I thought I would add in the representation of the value it was comparing.
using System;
class ArrayEx3
{
static void Main()
{
char[] array1 = { 'a', 'E', 'i', 'o', 'u' };
char[] array2 = { 'A', 'e', 'I', 'O', 'U' };
for (int i = 0; i < array1.Length; i++)
{
if (array1[i] > array2[i])
{
Console.WriteLine(" {0} is {2} bigger than {1} which is {3}", array1[i], array2[i],((int)array2[i].ToChar()),((int)array2[i].ToChar()));
}
else
{
Console.WriteLine(" {0} is bigger than {1}", array2[i], array1[i]);
}
}
}
}
I am receiving this error.
C:\Users\Sayth\Documents\Scripts>csc ArrayEx3.cs
Microsoft (R) Visual C# Compiler version 4.0.30319.33440
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.
ArrayEx3.cs(14,104): error CS1061: 'char' does not contain a definition for
'ToChar' and no extension method 'ToChar' accepting a first argument of
type 'char' could be found (are you missing a using directive or an
assembly reference?)
ArrayEx3.cs(14,130): error CS1061: 'char' does not contain a definition for
'ToChar' and no extension method 'ToChar' accepting a first argument of
type 'char' could be found (are you missing a using directive or an
assembly reference?)
C:\Users\Sayth\Documents\Scripts>
Checking the Convert ToChar docs though http://msdn.microsoft.com/en-us/library/4db6awt7(v=vs.110).aspx shows that ToChar is in the System space so why am I getting this?