博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
字符串格式化,自动化属性赋值
阅读量:4649 次
发布时间:2019-06-09

本文共 1003 字,大约阅读时间需要 3 分钟。

/字符串格式化,自动化属性赋值

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1

{
    class Program
    {
        static void Main(string[] args)
        {
            //string[] names = { "ganquanfu", "ligang", "zhongshi" };
            //var res = names.Where(name => (name.IndexOf("gan") > -1));
            //foreach (var item in res)
            //{
            //    Console.WriteLine(item);
            //}
            string format = string.Empty;
            List<People> peoples = new List<People> (){
                                                        new People() { Name = "huhong", Age = 23 },
                                                        new People() { Name = "ligang", Age = 42 } ,
                                                        new People() { Name = "xiongbing", Age = 23 },
                                                        new People() { Name = "xiaoming", Age = 42 }
                                                       };
            Console.WriteLine(string.Format("{0,-10}\t\t{1}", "姓名","年龄"));
            foreach (var item in peoples)
            {
                format = string.Format("{0,-10}\t\t{1}", item.Name, item.Age);//负数表示左对齐,整数表示右对齐
                Console.WriteLine(format);
            }

            Console.Read();

        }
    }

    class People

    {
        public string Name { get; set; }
        public int Age { get; set; }
    }
}

 

转载于:https://www.cnblogs.com/ganquanfu2008/archive/2013/04/25/3043485.html

你可能感兴趣的文章
转 小辉_Ray CORS(跨域资源共享)
查看>>
Linux安装postgresql
查看>>
MyBatis启动:MapperStatement创建
查看>>
【 全干货 】5 分钟带你看懂 Docker !
查看>>
[转]优化Flash性能
查看>>
popStar手机游戏机机对战程序
查看>>
Java Web项目结构
查看>>
lambda表达式树
查看>>
二次注入原理及防御
查看>>
会话记住已登录功能
查看>>
Linux内核分析——可执行程序的装载
查看>>
儿子和女儿——解释器和编译器的区别与联系
查看>>
第一阶段冲刺3
查看>>
父类引用指向子类对象
查看>>
网页如何实现下载功能
查看>>
IT男专用表白程序
查看>>
读《大道至简》第六章感想
查看>>
ef linq 中判断实体中是否包含某集合
查看>>
章三 链表
查看>>
Solution for Concurrent number of AOS' for this application exceeds the licensed number
查看>>