I am in the early stages of learning c# and am currently "fixing" a project (as an exercise).
I've come across this code but I can't make sense of it.
List<CartLine> cartList = Lines as List<CartLine>;
Up to now my usage of Lists has been pretty standard
List<T> newList = new List<T>
And similar constructions.
I'm mostly hung up on where "new" keyword went and what "as" is really doing here. Is there another way of writing the above code that I may be more familiar with (to wrap my head around)?
FYI "CartLine" is a class:
{
public int OrderLineId { get; set; }
public Product Product { get; set; }
public int Quantity { get; set; }
}
and Lines is linked by the IEnumerable
public IEnumerable<CartLine> Lines => GetCartLineList();
Sorry if this is a bit obvious for many of you. I read up on the MS Documentation of AS, but still a bit lost and i can't get great search results regarding its usage.