C# Finding the maximum value of a string with linq
问题 This is what I have and it keeps returning null. It doesn't recognize the Convert.toInt32 when I add a where statement var maxTopID = (from max in dbcontext.Topics.Local select max.TopicID).Max(); 回答1: How about converting the TopicID in SELECT and use String.IsNullOrEmpty() to remove empty string, like: var maxTopID = (from max in dbcontext.Topics.Local where !String.IsNullOrEmpty(max.TopicID) select Convert.ToInt32(max.TopicID)).Max(); See the Demo 回答2: I think you are saying that TopicID