ant-design-blazor/components/core/Extensions/DataConvertionExtensions.cs
老九 b6f21b5cf7 perf: Optimize for value converting performance (#720)
* 使用UnSafe替换表达树的编译实现,提高性能

* fix: translate the comments

Co-authored-by: ElderJames <shunjiey@hotmail.com>
2020-10-25 19:00:51 +08:00

20 lines
572 B
C#

using System.Runtime.CompilerServices;
namespace AntDesign.core.Extensions
{
public static class DataConvertionExtensions
{
/// <summary>
/// Converts the generic type TFrom to the specified TTo type
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <typeparam name="TTo"></typeparam>
/// <param name="fromValue"></param>
/// <returns></returns>
public static TTo Convert<TFrom, TTo>(TFrom fromValue)
{
return Unsafe.As<TFrom, TTo>(ref fromValue);
}
}
}