小编Moh*_*ari的帖子

整数蓝色,短+ +短问题

C#中的程序:

short a, b;
a = 10;
b = 10;
a = a + b; // Error : Cannot implicitly convert type 'int' to 'short'.

// we can also write this code by using Arithmetic Assignment Operator as given below

a += b; // But this is running successfully, why?

Console.Write(a);
Run Code Online (Sandbox Code Playgroud)

c# int types short

68
推荐指数
4
解决办法
1万
查看次数

在Float中,为什么?

long b = 99;  
float c = 99.0F;  
//b = c; //Error : Cannot implicitly convert type 'float' to 'long'.
c = b; // Running Successfully.  Why?
Run Code Online (Sandbox Code Playgroud)

为什么数据类型的大小和隐式转换没有问题?我们知道
的大小floatlong不同之处在下面给出...

Console.WriteLine("Long  : " + sizeof(long)); // Output --> Long : 8
Console.WriteLine("Float : " + sizeof(float));// Output --> Float: 4
Run Code Online (Sandbox Code Playgroud)

c# floating-point types

8
推荐指数
2
解决办法
7567
查看次数

跑车C =新司机(); 在C#中

假设我们有两个类Car和Driver,
我们可以制作像这样的对象

Car c=new Driver();
Run Code Online (Sandbox Code Playgroud)

并且能够调用汽车类的成员而不是驱动程序类的成员为什么和什么时候??

c# class object

0
推荐指数
1
解决办法
371
查看次数

标签 统计

c# ×3

types ×2

class ×1

floating-point ×1

int ×1

object ×1

short ×1