我想轉換VB C# 到C# 無需使用 using Microsoft.VisualBasic; using Microsoft.VisualBasic.CompilerServices;
我卡在If Bool 判斷部分和Operators除法。
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
public string SetBytes(object Bytes)
{
string SetBytesRet = default;
if (Conversions.ToBoolean(Operators.ConditionalCompareObjectGreaterEqual(Bytes, 1073741824, false)))
{
SetBytesRet = Strings.Format(Operators.DivideObject(Operators.DivideObject(Operators.DivideObject(Bytes, 1024), 1024), 1024), "#0.00") + " GB";
}
else if (Conversions.ToBoolean(Operators.ConditionalCompareObjectGreaterEqual(Bytes, 1048576, false)))
{
SetBytesRet = Strings.Format(Operators.DivideObject(Operators.DivideObject(Bytes, 1024), 1024), "#0.00") + " MB";
}
else if (Conversions.ToBoolean(Operators.ConditionalCompareObjectGreaterEqual(Bytes, 1024, false)))
{
SetBytesRet = Strings.Format(Operators.DivideObject(Bytes, 1024), "#0.00") + " KB";
}
else if (Conversions.ToBoolean(Operators.ConditionalCompareObjectLess(Bytes, 1024, false)))
{
SetBytesRet = Conversions.ToString(Operators.ConcatenateObject(Conversion.Fix(Bytes), " Bytes"));
}
return SetBytesRet;
}