Latest

把衣服的鬆緊帶穿回去的方法

當衣服的鬆緊帶如果有一邊跑進去,要如何解決? 有一辦法可以先把鬆緊帶全部抽出來,再用直徑比較細的原子筆管讓鬆緊帶穿進去,之後在順著褲子的鬆緊帶洞口用手把它穿過去。這方法我用在我的褲子上,最後是成功的。 (最近才把以前的照片紀錄上傳,具體步驟只能依印象而寫) 鬆緊帶 準備工具除了鬆緊帶,還有:剪刀、美工刀、膠帶、原子筆管 鬆緊帶穿過筆管後,可以用膠帶把筆管前端和鬆緊帶黏住,以防鬆緊帶穿到一半跑出筆管 有些地方穿不過去時可以用剪刀或美工刀稍微開個小洞 完成後就卸下膠帶和筆管!

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; }
    }

留言

這個網誌中的熱門文章

Win 10 變更注音輸入法選字窗的大小

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