using System;
using System.Collections.Generic;
using System.Text;namespace HelloWorld_Console
{
class HelloWorld
{
static void Main(string[] args)
{ int result;
long vall = 1;
long val2 = 2;
result = (int)vall + val2;//强制转换 错误无法将类型“long”隐式转换为“int”。存在一个显式转换(是否缺少强制转换?)//
}
}
}
using System.Collections.Generic;
using System.Text;namespace HelloWorld_Console
{
class HelloWorld
{
static void Main(string[] args)
{ int result;
long vall = 1;
long val2 = 2;
result = (int)vall + val2;//强制转换 错误无法将类型“long”隐式转换为“int”。存在一个显式转换(是否缺少强制转换?)//
}
}
}
----------------------
result = (int)vall +(int) val2;orresult = (int)(vall + val2);