当前位置: 首页 > news >正文

杭州网站设计的公司网站建设的要点

杭州网站设计的公司,网站建设的要点,常德网站建设开发哪家好,百度网站建设策划书范文目录 1、项目介绍 2、为项目添加依赖 3、代码中导入命名空间 4、代码中使用 示例 1:string转换 示例 2:object转换 1、项目介绍 Com.Gitusme.Net.Extensiones.Core是一个.Net扩展库。当前最新版本1.0.4,提供了常见类型转换&#xff0c…

目录

1、项目介绍

2、为项目添加依赖

3、代码中导入命名空间

4、代码中使用

示例 1:string转换

示例 2:object转换


1、项目介绍

Com.Gitusme.Net.Extensiones.Core是一个.Net扩展库。当前最新版本1.0.4,提供了常见类型转换,可减少代码量,并提高编程效率。基于.Net Standard 2.0开发,支持windows、linux、IOS等多平台。

2、为项目添加依赖

打开NuGet包管理,搜索”Com.Gitusme.Net.Extensiones.Core“关键字,安装最新版本。

3、代码中导入命名空间

using Com.Gitusme.Net.Extensions.Core;

4、使用示例

示例 1:string转换

           // Example 1: 判断string是否为null
            string str = null;
            if (str.IsNullOrEmpty())
            {
                System.Console.WriteLine("Example 1 输出结果:" + "null");
            }

            // Example 2: 判断string是否匹配正则
            string hello = "Hello, gitusme";
            var isMatch = hello.IsMatch(@"Hello, \w+");
            System.Console.WriteLine("Example 2 输出结果:" + isMatch);

            // Example 3: 将string转换为Json实体对象
            string json = "{\"Id\":0,\"Name\":\"Json Object\"}";
            var jsonObj = json.ToJsonObject<MyJsonObject>();
            System.Console.WriteLine("Example 3 输出结果:" + jsonObj.Name);

            // Example 4: 将string转换为Xml实体对象
            string xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" id=\"0\">" +
                "<name>Xml Object</name>" +
                "</root>";
            var xmlObj = xml.ToXmlObject<MyXmlObject>();
            System.Console.WriteLine("Example 4 输出结果:" + xmlObj.Name);

            // Example 5: 将string转换为DateTime
            string date = "2023/10/22 21:32:00";
            var dateTime = date.ToDateTime();
            System.Console.WriteLine("Example 5 输出结果:" + dateTime.ToString());

            // Example 6: 将string转换为字符数组
            string gitusme = "gitusme";
            var array = gitusme.ToCharArray();
            System.Console.WriteLine("Example 6 输出结果:" + array);

            // Example 7: 将string转换为int32
            string intStr = "100";
            var intValue = intStr.ToInt32() + 10;
            System.Console.WriteLine("Example 7 输出结果:" + intValue);

            // Example 8: 将string转换为decimal
            string decimalStr = "3.141592653589793238462643383279502884197";
            var decimalValue = decimalStr.ToDecimal();
            System.Console.WriteLine("Example 8 输出结果:" + decimalValue);

            // Example 9: 将string转换为uri
            string uriStr = "https://github.com/gitusme/Com.Gitusme.Net.Extensiones";
            var uriValue = uriStr.ToUri();
            System.Console.WriteLine("Example 9 输出结果:" + uriValue.Host);

            // Example 10: 将string转换为color
            string colorStr = "#aabbcc";
            var colorValue = colorStr.ToColor();
            System.Console.WriteLine("Example 10 输出结果:" + colorValue);

运行结果:

示例 2:object转换

            // Example 1: 判断对象是否为null
            MyObject obj = null;
            if (obj.IsNull())
            {
                System.Console.WriteLine("Example 1 输出结果:" + "null");
            }

            // Example 2: 对象为null的时候,返回传入的默认值
            var def = obj.OrDefault(new MyObject());
            System.Console.WriteLine("Example 2 输出结果:" + def);

            // Example 3: 如果对象不为null,则执行传入的Action行为
            def.IfPresent((it) =>
            {
                System.Console.WriteLine("Example 3 输出结果:" + it.Name);
            });

            // Example 4: 将Xml对象转换为Xml文本
            var xmlObj = new MyXmlObject();
            string xml = xmlObj.ToXml();
            System.Console.WriteLine("Example 4 输出结果:" + xml);

            // Example 5: 将Json对象转换为Json文本
            var jsonObj = new MyJsonObject();
            string json = jsonObj.ToJson();
            System.Console.WriteLine("Example 5 输出结果:" + json);

运行结果:

您能够认真学习完本篇,实属不易,欢迎点赞加关注,收藏交流和探讨。

http://www.yayakq.cn/news/932234/

相关文章:

  • 新手学做网站12天婴重庆渝网站建设
  • 镇江外贸型网站建设高清logo网站
  • 建设银行信用卡在网站激活后如何设置密码展示型企业网站建设
  • 做网站买什么服务器 便宜嵌入式软件开发要求
  • 为什么企业网站不是开源系统广西建设厅培训中心
  • 做网站常熟西安seo培训
  • 帮别人做网站推广犯法吗阜阳网站开发招聘
  • 余姚市建设局网站工商营业执照查询官网
  • 亿唐网不做网站做品牌考试题东莞网站建设报价
  • 上线了怎么建网站网页设计模板怎么套用
  • 青岛网站定制多少钱广州做网站公司培训
  • 安徽住房和城乡建设部网站wordpress输出某一分类的文章
  • 做网站模版南头专业英文网站建设公司
  • p2p种子网站建设建站之星
  • 怎么选择企业建站公司南和网站建设公司
  • 网站建设哪家有名扁平化设计 网站
  • python+网站开发+prf程序员必知的网站
  • 微信公众平台怎么做微网站阳泉建设局网站
  • 步步高网站建设报告php与wordpress
  • 显示代码wordpressseo是什么专业
  • 高端汽车网站建设青岛网站seo分析
  • 专门做杂志的网站有哪些个体户核名查询系统
  • 网站建设和维护岗位的职责app制作教程视频全集
  • 永清网站建设新手建站网址
  • 大气物流网站模块做网站需要什么学专业
  • 镇江网站建站郴州网站建设设计制作
  • 东莞技术支持 骏域网站建设wordpress不登陆不能看内容
  • 网站开发需要的知识和技术浙江省建设厅新网站人员无法查询
  • 大庆企业网站建设公司网站建设合同封皮
  • 用安卓手机做网站主机wap网站源码.net