Latest

環保洗碗去油方法

幾年前試著尋找有無環保洗碗去油的方法,以下是列表: 草木灰 洗米水 熱水 豬胰子 熟麵水 衛生紙 廚房紙巾 玉米麵粉 茶籽粉 無患子 橙子皮 小蘇打 (NaHCO₃) 皂莢 咖啡渣 茶葉渣 後來發覺一個不錯的方法其實是用吃飯擦嘴巴的衛生紙或一些剩餘衛生紙去擦吃剩碗中的油,如果太油則是用廚房紙巾去擦拭,最後再加上相關去油的物質。而水溫很冷的話則開熱水去清洗。通常還是搭配著用,太油的話有時候還是得用洗碗精,但可以選購比較環保的品牌。

Template之標籤取代

using System;
using System.Reflection;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "Hello! This is {Student.Name}. My ID is {Student.ID}.";
            //string str2 = "你好!我是{Student.Name},我的ID為{Student.ID}。";
            int size = 0;

            Student std = new Student();
            std.Name = "Tim";
            std.ID = "44123";


            string[] temp = str.Split(' ');//以空白做分界來切割

            //算出有幾個標籤
            foreach (string a in temp)
            {
                //Console.Write(a + "\n");
                if (a.IndexOf('{') != -1)
                    size++;
            }

            string[] token = new string[size];
            int count = 0;

            //把標籤拿出來並存入陣列
            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i].IndexOf('{') != -1)
                {
                    token[count] = temp[i].Substring(0, temp[i].IndexOf('}') + 1);
                    count++;
                }
            }

            //取物件的值
            Type myType = typeof(Student);
            PropertyInfo[] prop = myType.GetProperties();

            count = 0;

            //把標籤取代為值
            foreach (var p in prop)
            {
                str = str.Replace(token[count], (string)p.GetValue(std));
                count++;
            }

            Console.Write(str);
            Console.Read();
        }
    }

    class Student
    {
        public string Name { get; set; }
        public string ID { get; set; }
    }

留言

這個網誌中的熱門文章

國泰世華信用卡 異常簽帳消費

打火機處理記 (注意,有爆炸危險!) (2021.09.11 更新)