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

大连网络营销网站旅游网站建设的组织性

大连网络营销网站,旅游网站建设的组织性,如何攻破wordpress,十堰seo优化服务目录 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/168090/

相关文章:

  • 天津做网站费用网站搭建平台价格
  • 网站建设实例教程wordpress改二级域名
  • 如何建设好网站网站建设公司 知乎
  • 网站设计结构求个企业邮箱
  • 免费建设手机网站山西两学一做登录网站
  • 手机网站建设公台州seo网站排名
  • 陇南网站制作wordpress所需系统
  • 赣州建设局 网站网站空间是怎么开通的
  • 丹阳做网站用手机制作网站的软件
  • 网站建设技术主管中铁十六门网户登录
  • 上海网站seo外包伊川县住房和城乡建设厅网站
  • 自己怎么做搬家网站网站备案需要费用吗
  • 汽车维修东莞网站建设wordpress首页title哪里修改
  • 漳浦网站设计很多网站开发没有框架如何制作的
  • c 网站开发工程师招聘沈阳建设网站服务公司
  • 建立网站 多少钱长沙服务好的网络营销
  • 如何建立网站空间wordpress子主题空白
  • 谷歌搜索引擎首页吉林seo管理平台
  • 有做游戏广告的网站网站建1设公司
  • 重庆网站建设重庆最加科技做网站运营很累吧
  • 进qq空间上面没有网站关于门户网站建设的整改报告
  • 建站平台上建设的网站可以融资吗wordpress 表单 插件
  • 自己网站建设要维护网页搜索青骄第二课堂
  • 网站被挂广告怎么办做网站什么内容吸引人
  • 上栗县建设局网站seo怎么读
  • 蛋糕网站源码天津商城网站建设
  • 邳州网站建设北京百度推广投诉电话
  • 做网站要学编程麽中国建筑
  • 怎样查看网站是否被百度收录西安百度推广开户运营
  • 网站建设用到什么网站代运营多少钱