Skip to content

Instantly share code, notes, and snippets.

View rebornix's full-sized avatar
📓
Working from home

Peng Lyu rebornix

📓
Working from home
View GitHub Profile
@rebornix
rebornix / gist:3120198
Created July 16, 2012 03:08
ConvertToXml
public static XmlDocument ToXml(object thisObj)
{
XmlDocument propertyDoc = new XmlDocument();
XmlNode rootNode = propertyDoc.CreateElement(thisObj.GetType().Name.Replace("[]", "Array"));
propertyDoc.AppendChild(rootNode);
if (thisObj.GetType().IsArray)
{
Array objects = (Array)thisObj;
foreach (object obj in objects)
{
@rebornix
rebornix / gist:3120180
Created July 16, 2012 03:06
Convert InFix String to PostFix String
private static string ConvertInFixToPostFix(string inFixExpression)
{
if (inFixExpression == null || inFixExpression.Trim().Length == 0)
return inFixExpression;
inFixExpression = inFixExpression.Replace("(", " ( ");
inFixExpression = inFixExpression.Replace(")", " ) ");
inFixExpression = inFixExpression.ToLower();
string[] tokens = inFixExpression.Split(new string[] { }, StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length == 0 || tokens.Length == 1)