Here's how I'd do that. In your class which goes and reads the newer entries, make a property that will hold the last entryid. That can store the value for you, in your instance of the class. So when the method (in the same class) that reads the newer entries is called, it will just look at this entryid property, and pass that in to the SQL to read only ones that are newer than that (and then update the entryid with the newer last entryid).
As long as you always use that one instance of the class, your last entryid will be stored. This would be better than a global variable, as it uses the language as it was intended.
Something like this:
public class ReadNewestEntries {
public int entryId {get;set}
public List<someDataType> ReadNewEntries() {
// some code to read the database, using the entryId
// Get last ID read
entryId = dataList.Max(x => x.entryId);
}
}
// in main class:
ReadNewestEntries getNewEntries = new ReadNewestEntries();
// Then just keep this class instance around to use
List<someDataType> = getNewEntries.ReadNewEntries();
Your "global variable" is just the entryId int in the class itself, which will hold and keep for you your last ID read. I didn't test the above code out, but hopefully that helps you, and without using a global variable.