and i got a problem that i cant understand why it happning
when i first use this interface with int arry every thing work great but now im trying to do it with
arry of doubles that foreach loop work but it dosnt show the Current as i want it to show
i want the current return the temperatur in fernhait but its just stay the same
(sorry for my english)
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Temperature tem = new Temperature();
tem.temps = new double[] { 2.3, 4.5, 6.4, 6.7, 8.7 };
foreach (var i in tem.temps)
{
Console.WriteLine(i);
}
}
}
class Temperature : IEnumerable
{
public double[] temps { get; set; }
public IEnumerator GetEnumerator()
{
return new TempertatureIEnomerator { other = this };
}
class TempertatureIEnomerator : IEnumerator
{
public Temperature other {get;set;}
int size = -1;
public object Current
{
get
{
other.temps[size] = (other.temps[size] - 32) * (5 / 9);
return other.temps[size];
}
}
public bool MoveNext()
{
size++;
if (size < other.temps.Length)
return true;
return false;
}
public void Reset()
{
return;
}
}
}
}

New Topic/Question
Reply




MultiQuote




|