A
Akhil963
Guest
I would like to use NWCdecimal[] in Main while comparing it with decimal[] to get the output. However, I am not able to compare the two and getting error "Operator '==' cannot be applied to operands of type 'NWC' and 'int'" How this can be achieved? Also, NWCdecimal[] cannot be moved out of NWC class. (This is an incomplete code, just looking to be pointed in right direction)
public class NWC
{
public int Number { get; set; }
public int[] NWCdecimal = new int[20]
{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
}
public static int[] deci = new int[5]{0,1,4,5,10 };
in main when I compare
for (int i = 0; i < NWCdecimal.Length; i++)
{
for (int j = 0; j < deci.Length; j++)
{
if (NWCdecimal == deci[j])
{
Console.WriteLine(NWCdecimal);
}
else
{
Console.WriteLine(E);
}
}
this gives me error Operator '==' cannot be applied to operands of type 'NWC' and 'int'
Continue reading...
public class NWC
{
public int Number { get; set; }
public int[] NWCdecimal = new int[20]
{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
}
public static int[] deci = new int[5]{0,1,4,5,10 };
in main when I compare
for (int i = 0; i < NWCdecimal.Length; i++)
{
for (int j = 0; j < deci.Length; j++)
{
if (NWCdecimal == deci[j])
{
Console.WriteLine(NWCdecimal);
}
else
{
Console.WriteLine(E);
}
}
this gives me error Operator '==' cannot be applied to operands of type 'NWC' and 'int'
Continue reading...