Question: I have the following interfaces.

```
public interface IProductPrices
    {
        int ProductId { get; set; }
        string ProductCode { get; set; }
        List<IProductPrice> Prices { get; set; }
    }

public interface IProductPrice
    {
        int ProductId { get; set; }
        string PriceKey { get; }
        double Price { get; set; }
        int Id { get; set; }
    }

```

**Snippet**

```
//productPrices is of type IProductPrices
//temp is of type IProductPrice

```

.

```
........
var finalPriceList = new List<ABC.Model.ProductPrice>();
foreach (var item in productPrices)
    {
        foreach (var temp in item.Prices)
        {
            var prodPrice = new ABC.Model.ProductPrice()
            {
                Price = temp.Price,
                ProductCode = temp.ProductCode
            };
            finalPriceList.Add(prodPrice);
        }
    }
.....

```

In the snippet above there is the line

```
foreach (var temp in item.Prices)

```

I would like to select from `[item.Prices]` only if the `[PriceKey]` is equal to `"ABC"`. If `[PriceKey]=="ABC"` does not exist then I would like to select the item with the lowest `[Price]`.

How to achieve this ?

Answer: 
`printf` always uses the UART as STDOUT. 
If you use the simulator you could enable UART IO under Project Properties. Know it's your choice if you like to see your printed data in a file or in an output window.
Why?  

Because mplabX IDE doesn't have access to your hardware. I guess you use debugging (you haven't written), then your debugging (unit? hardware? software?) might not support it. 

Where I can find the printed result?  

That depends on how you have written your \_mon\_putc() function. `By default, MPLAB® XC32's libraries use UART2 for STDOUT.` For example for [PIC32MZ EF CURIOSITY DEVELOPMENT BOARD](http://ww1.microchip.com/downloads/en/DeviceDoc/70005282B.pdf) UART2 (signal U2TX) would be on pin 7 on MCU, that would be pin 4 on J11 or pin 13 on J10 or pin 5 on connector J14. The best would be to buy a cheap UART<->USB converter to read from that uart.

Any info?  

Sure.  

[(XC32) How do I instruct printf to output to UART1 or other UART channels instead of UART2?](http://microchipdeveloper.com/faq:81)  

[Debugging: Can I redirect printf or putchar to the MPLAB X console?](http://www.microchip.com/forums/m1037661.aspx)  

[stdio over uart1 example](https://gist.github.com/raivisr/5007565)  

The mplab simulator uses uart1 as stdout and the simulator connects a simulated "reader" to that uart which shows it's output on mplab console. The uart on your real hardware, I guess, isn't anyhow connected to the computer.