How can I find the last element in a List<>?

后端 未结 13 1344
离开以前
离开以前 2020-12-12 21:43

The following is an extract from my code:

public class AllIntegerIDs 
{
    public AllIntegerIDs() 
    {            
        m_MessageID = 0;
        m_Messa         


        
13条回答
  •  无人及你
    2020-12-12 21:58

    I would have to agree a foreach would be a lot easier something like

    foreach(AllIntegerIDs allIntegerIDs in integerList)
    {
    Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\n", allIntegerIDs.m_MessageID,
    allIntegerIDs.m_MessageType,
    allIntegerIDs.m_ClassID,
    allIntegerIDs.m_CategoryID,
    allIntegerIDs.m_MessageText);
    }
    

    Also I would suggest you add properties to access your information instead of public fields, depending on your .net version you can add it like public int MessageType {get; set;} and get rid of the m_ from your public fields, properties etc as it shouldnt be there.

提交回复
热议问题