KyCommonExtend 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package KyCommonExtend --version 1.2.0
                    
NuGet\Install-Package KyCommonExtend -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KyCommonExtend" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KyCommonExtend" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="KyCommonExtend" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add KyCommonExtend --version 1.2.0
                    
#r "nuget: KyCommonExtend, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package KyCommonExtend@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KyCommonExtend&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=KyCommonExtend&version=1.2.0
                    
Install as a Cake Tool

Install-Package Oclean.Core.Ability.Common

使用方式

// ============== 1. 字符串转换 ============== object nullObj = null; string str1 = nullObj.ToNullString(); // 输出:空字符串(默认值) string str2 = nullObj.ToNullString("默认值"); // 输出:"默认值" string str3 = " 12345 ".ToNullStringNoSpace(); // 输出:"12345"

// ============== 2. 数值类型转换 ============== object numObj = "123.456"; int intVal = numObj.ToInt(); // 输出:123(小数向下取整) long longVal = numObj.ToLong(); // 输出:0(字符串含小数点无法转long,返回默认值0) long longVal2 = "7890".ToLong(100); // 输出:7890(解析成功,返回实际值) double doubleVal = "3.14".ToDouble(); // 输出:3.14 decimal decimalVal = "99.99".ToDecimal(50); // 输出:99.99 float floatVal = "1.23".ToFloat(0.5f); // 输出:1.23f bool boolVal = "1".ToBool(); // 输出:true

// ============== 3. 日期转换与处理 ============== object dateObj = "2025-11-27"; DateTime dateVal = dateObj.ToDateTime(); // 输出:2025-11-27 00:00:00 DateTime now = DateTime.Now; DateTime monday = now.GetMonday(); // 获取当前日期所在周的周一(仅日期部分) long timeStamp = now.ToTimeStamp(); // 转换为Unix时间戳(秒级,基于1970-01-01) int weekNum = now.WeekOfYear(); // 获取当前日期是一年中的第几周

// ============== 4. MAC地址转换 ============== long macLong = ObjectExtends.MacStringToLong("00:1A:2B:3C:4D:5E"); string macStr = ObjectExtends.MacLongToString(macLong); // 输出:"00:1A:2B:3C:4D:5E"

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.0 114 4/21/2026
1.4.0 127 1/14/2026
1.3.0 455 12/10/2025
1.2.1 201 11/27/2025
1.2.0 195 11/27/2025
1.1.0 198 11/27/2025
1.0.0 209 11/6/2025