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

做网站dreamwa电脑优化工具

做网站dreamwa,电脑优化工具,wordpress推送到百度,新网站建设目录 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.dinnco.com/news/29725.html

相关文章:

  • 您提供的产品已经提交过网站备案成都业务网络推广平台
  • 商务网站建设实训心得图片外链生成器
  • 赤城县城乡建设局网站百度seo优化排名
  • 海外推广大使人员优化方案
  • 做双语网站多少钱附近广告公司联系电话
  • wordpress中常用插件安装包厦门seo推广外包
  • 用自己点电脑做电影网站seo如何快速排名百度首页
  • 网站域名想更换要怎么做长沙推广公司
  • 徐州网站建设网络推广贵阳关键词优化平台
  • 网站栏目管理建设百度seo原理
  • 企业网站建设的好处网络营销策划方案框架
  • 网站空间可以通过什么获取随州seo
  • 中创高科官方网站fifa最新排名出炉
  • 158百事通做网站是诈骗吗网络营销策划书的结构
  • 哈尔滨做网站企业杭州小程序建设公司
  • 自己的卡盟网站怎么做分站江苏疫情最新消息
  • 网站开发完整项目案例关键词挖掘网站
  • 如何做盗版网站百度搜索关键词排名
  • 传销公司做网站什么罪名微信推广怎么弄
  • 深圳市设计师服务平台seo软件优化工具软件
  • 深圳wordpress外贸网站建设网站建设优化公司
  • led外贸网站制作网优工程师前景和待遇
  • 大连信联科技做的网站怎么样厦门关键词优化网站
  • 兼职做网站赚钱吗他达拉非什么是
  • 公司建设网站费用会计怎么记怎么让网站被百度收录
  • 百度开发平台seo免费外链工具
  • xampp怎么做网站搜索引擎seo关键词优化效果
  • 动态网站的滚动图片怎么做文案代写收费标准
  • 刚做的网站怎么才能搜索到百度竞价推广公司
  • 网页版梦幻西游地宫迷阵攻略seo店铺描述