End Google Ads 201810 - BS.net 01 --> Hi,

I am new to c#. I am reading the data from log file

And the outpur is as shown in the image.

Now I want to separate the messages of RED,YELLOW and GREEN message ID's into objects of common classes.

I am trying something like this in the following code.

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Text.RegularExpressions; using ConsoleApplication13; namespace ConsoleApplication13 { #region Buses public enum Buses { CANBusRed = 1, CANBusYellow = 2, CANBusGreen = 3, CANBusOrange = 4 }; #endregion #region Member Variables /// /// Objects of common classes /// public static CANBusDetails CANBusRedDetails = null; public static CANBusDetails CANBusYellowDetails = null; public static CANBusDetails CANBusGreenDetails = null; public static CANBusDetails CANBusOrangeDetails = null; #endregion public class CANBusDetails { public List<span class="code-keyword"string/span> CANBusMsgIDList { get; set; } } public class CANBusMsgIdMap { string msgId; public Buses Bus { get; set; } //public string CANBus { get; set; } //public string CANMsgId { get; set; } public string MsgId { get { if (!String.IsNullOrEmpty(msgId)) return msgId.ToUpper(); else return string.Empty; } set { msgId = value; } } public CANBusMsgIdMap(Buses bus, string msgId) { this.Bus = bus; this.msgId = msgId; } public override string ToString() // Equals,GetHash also there.here I am using ToString { return this.Bus + ", " + this.msgId; } } class Program { static void Main(string[] args) { string[] fileContents = null; List CANMsgIdList = new List(); //String seclogPath1 = "C:\\Users\\Vivek\\Desktop\\log files\\1302_P3\\logg2.asc"; String seclogPath1 = @"\\global.scd.scania.com\home\se\121\valhbc\Desktop\log files\1302_P3\logg2.asc"; fileContents = File.ReadAllLines(seclogPath1); for (int Index = 0; Index < fileContents.Length; Index++) { string CANMsgId = string.Empty; string[] spaceSeperator = new string[] { " " }; string[] lineWords = (fileContents[Index].Trim()).Split(spaceSeperator, StringSplitOptions.RemoveEmptyEntries); // If the number of words in a line is less than 3 then its not a valid entry. if (lineWords.Length < (2 + 1)) continue; // If a CAN Msg Id is valid, it should end with 'x'. If it doesnot end with 'x', // then skip the entry and go to the next line of log file if (lineWords[2].EndsWith("x")) CANMsgId = lineWords[2].TrimEnd('x'); else continue; // Check the format of the CAN Msg Id, whether Hex or not. if (Regex.IsMatch(CANMsgId, @"^[0-9A-Fa-f]+$")) { Buses CANBus = (Buses)Enum.Parse(typeof(Buses), (lineWords[1])); CANMsgIdList.Add(new CANBusMsgIdMap(CANBus, CANMsgId)); } } //foreach (CANBusMsgIdMap CANBusMsgIdMap in CANMsgIdList) //{ // Console.WriteLine(CANBusMsgIdMap); //} //<span class="code-comment">for (double i = 0; i