Q: Find item if it exists I have list with items and I check if an item exists in a List. If it exists, I try to find it.
I think that it has a little overhead, because I currently make two passes over the list. Is it possible to do in single pass?
Currently I have.
public partial class Item
{
    public string text;
    public int id;
}
....
static List<Item> data = new List<Item>();
static stub = new Item() { text = "NaN", id = -1 };
public static Item Get(int targetId)
{
    if (data.Any(f => f.id == targetId) == false)
    {
        return stub;
    }
    return data.Find(f => f.id == targetId);
}

I want something like
...
public static Item Get(int targetId)
{
    Item result;
    result = data.Find(f => f.id == targetId);
    if (result == null)
    {
        return stub;
    }
    return result;
}


A: You seem to be looking for FirstOrDefault():
Item _stub = new Item
{ 
    text = "NaN", 
    id = -1 
};

public Item FindByID(int id)
{
    // Find the first item that has the provided id, or null if none exist.
    var existingItem = data.FirstOrDefault(i => i.id == id);

    // When not found, return the _stub
    return existingItem ?? _stub;
}

You also may want to reconsider your naming conventions and whether you actually need these members to be static.

A: You can use List.FindIndex:
public static Item get(int i)
{
    int index = data.FindIndex(item => item.id == i);
    if (index == -1) return stub;
    return data[index];
}

If it's actually an array you can use Array.FindIndex:
public static Item get(int i)
{
    int index = Array.FindIndex(data, item => item.id == i);
    if (index == -1) return stub;
    return data[index];
}


A: So FirstOrDefault() is the way to go. You can also use SingleOrDefault() if there is only supposed to be one item in that list.
    static stub = new Item() { text = "NaN", id = -1 };
    public static Item get(int i)
    {
        Item result;
        result = data.FirstOrDefault(f => f.id == i);

        if (result == null)
        {
            return stub;
        }

        return result;
    }


A: I think you can try this:
return data.Find(f => f.id == i) ?? stub;


A: I use an extension method for exactly this purpose
public static T FirstOrSpecificDefault<T>(this IEnumerable<T> list, 
                                       Func<T, bool> predicate, T defaultValue)
{
     return list.FirstOrDefault(predicate) ?? defaultValue;
}

usage in your case would be 
Item result = list.FirstOrSpecificDefault(f => f.id == i, stub);

