📄 commonfunc.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using feiyun0112.cnblogs.com.CSDNReader.Model;
using System.Net;
using System.Xml.Serialization;
using System.IO;
namespace feiyun0112.cnblogs.com.CSDNReader.Functions
{
class CommonFunc
{
private CommonFunc()
{
}
public static bool IsNumeric(string strNum)
{
try
{
int.Parse(strNum);
}
catch
{
return false;
}
return true;
}
public static void SerializeObject(object o, string path)
{
System.Runtime.Serialization.IFormatter obj = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); Stream oS = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write); obj.Serialize(oS, o);
oS.Close();
oS = null;
o = null;
return;
}
public static object DeserializeObject(string path)
{
if (!File.Exists(path)) return null;
FileStream oS = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
System.Runtime.Serialization.IFormatter obj = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
object o;
try
{
o = obj.Deserialize(oS);
}
finally
{
oS.Close();
oS = null;
obj = null;
}
return o;
}
public static void Addlog(string log)
{
System.Diagnostics.Debug.WriteLine(string.Format("{0}:{1}", DateTime.Now, log));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -