The official documentation looks straightforward to me:
The foreach statement repeats a group of embedded statements for each element in an array or an object collection that implements the System.Collections.IEnumerable or System.Collections.Generic.IEnumerable<T> interface.
Note that kai's answer, backed by the C# Language Specification, shows that the documentation is too restrictive: it is not necessary to implement one of those interfaces in order to use a class with a foreach. Those are implementation details which are interesting by themselves, but irrelevant for your original question, since in your sample code, you're actually using an IEnumerable.
What happens is that the sequence you use is an array, and, according to the documentation, emphasis mine:
Array types are reference types derived from the abstract base type Array. Since this type implements IEnumerable and IEnumerable<T>, you can use foreach iteration on all arrays in C#.
Similarly, you could look at the definition of the Array class:
public abstract class Array : ICloneable, IList, ICollection,
IEnumerable, IStructuralComparable, IStructuralEquatable
See the IEnumerable among the interfaces?
More interestingly, exploring the result of typeof(int[]) gives you this list for ImplementedInterfaces property:
typeof(ICloneable)
typeof(IList)
typeof(ICollection)
typeof(IEnumerable)
typeof(IStructuralComparable)
typeof(IStructuralEquatable)
typeof(IList<Int32>)
typeof(ICollection<Int32>)
typeof(IEnumerable<Int32>)
typeof(IReadOnlyList<Int32>)
typeof(IReadOnlyCollection<Int32>)
where you can see the additional generic interfaces as well. (This also explains why you can write IList<int> a = new[] { 1, 2, 3 };.)
Similarly, List<T>, ConcurrentQueue<T>, etc. implement IEnumerable and Enumerable<T>.
So when you say that:
And also , arrays are working without implementing IEnumerable.
this is simply not true. Arrays are implementing IEnumerable. As for:
I have following class that didnt implement IEnumerable but working perfectly with foreach.
it would be interesting to see the actual code (the one you have in your question uses an array). What is probably happening is that your class, without explicitly declaring IEnumerable or IEnumerable<T> among its interfaces, implements a more specific interface, such as ICollection<T>, which, in turn, inherits from IEnumerable:
public interface ICollection<T> : IEnumerable<T>, IEnumerable
And if not, well, you are probably in the case illustrated in kai's answer.
foreachwithout implementing the interface, then saying that you must implement the interface to useforeachis objectively false. This is basically akin to saying that you can onlyawaitTasks or that you can only use LINQ queries withIEnumerableorIQueryable. Just because they are the most common doesn't mean that it has to be that way.