SoFunction
Updated on 2025-03-07

C# uses Dictionary to split strings and logging methods

Dictionary<string, string>Split string

        private Dictionary<string, string> GenDictionary(byte[] inMsg)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			string arg= (inMsg);
			char[] trimChars = new char[1];
			string text = (trimChars);
			string[] array = (new char[]
			{
				';'
			});
			for (int i = 0; i < ; i++)
			{
				string text2 = array[i];
				if (!(text2) && !((new char[]
				{
					':'
				})[0]))
				{
					((new char[]
					{
						':'
					})[0], ((new char[]
					{
						':'
					})[0] + ":", ""));
				}
			}
			return dictionary;
		}

How to record logs

        public static void WriteLog(string strLog)
        {
            string pathName =  + "\\LOG\\" + ("yyyyMMdd");
            string FileName = "";
            FileName = pathName + "\\" + FileName;
            if (!(pathName))
            {
                (pathName);
            }
            FileStream fileStream = null;
            StreamWriter streamWriter = null;
            try
            {
                if ((FileName))
                {
                    //Add record content                    fileStream = new FileStream(FileName, , );
                }
                else
                {
                    //Create a new file and record it                    fileStream = new FileStream(FileName, , );
                }
                streamWriter = new StreamWriter(fileStream);
                ("【" + ("yyyy-MM-dd HH:mm:ss") + "】" + strLog);
            }
            finally
            {
                ();
                ();
            }
        }

This is all about this article about Dictionary<string, string> splitting strings and recording log methods. I hope it will be helpful to everyone's learning and I hope everyone will support me more.