| |

VerySource

 Forgot password?
 Register
Search
Author: 393736105

How to represent 0 of short type?

[Copy link]

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-5-14 21:00:02
| Show all posts
short is Int16, the two are exactly the same
Reply

Use magic Report

0

Threads

13

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-5-16 14:45:01
| Show all posts
There is no similar way to declare,
can only be
short a = 0;
Reply

Use magic Report

0

Threads

10

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-5-23 20:15:02
| Show all posts
int
16
Reply

Use magic Report

1

Threads

31

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

 Author| Post time: 2020-5-24 22:15:01
| Show all posts
There is a variable of type object, it may be an integer, small integer, large integer, may be a Boolean value,
The question now is how do I know if the value represented by the variable of this object is 0 or boolean False.
If the variable of this object is obj,
short sv = 0;
object obj = sv;
So how do I show that obj is the value of 0 at this time?
Yes: obj == (short) 0 ???

Also possible:
long lv = 0L;
object obj = lv;
What about this time?

Do I want to compare all (short) 0, (long) 0, (int) 0; false ... etc. one by one?

Only this question is because
object.Equals (lv, 0) cannot be compared.

Do you know what the problem is?
Reply

Use magic Report

0

Threads

32

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-5-30 14:00:01
| Show all posts
For the object, no one knows what type it is except for the one assigned. Has nothing to do with short
Reply

Use magic Report

1

Threads

31

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

 Author| Post time: 2020-6-1 18:30:01
| Show all posts
The answer upstairs is wrong ...

It has nothing to do with short, I know.

I want to know whether obj represents 0
Reply

Use magic Report

0

Threads

32

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-6-1 23:45:01
| Show all posts
Object does not have the concept of 0, it is not necessarily the value type, let alone wait for it not equal to 0.
Reply

Use magic Report

1

Threads

31

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

 Author| Post time: 2020-7-23 11:00:01
| Show all posts
I now know that it is a value type,
I also know that it puts a short type, or long type, or int type value, and this value is 0,
How do I use the program to judge now!
The one upstairs didn't understand what I meant at all!
Reply

Use magic Report

1

Threads

31

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

 Author| Post time: 2020-7-25 16:45:01
| Show all posts
E.g:
short a = 0;
object obj = a;
bool b = object.Equals(obj, 0);
System.Console.WriteLine(a);
The output is false, this method Equals is not working. How can we know that the value represented by obj is 0?
Reply

Use magic Report

1

Threads

31

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

 Author| Post time: 2020-7-25 17:15:01
| Show all posts
(The above is wrong, it is like this)
E.g:
short a = 0;
object obj = a;
bool b = object.Equals(obj, 0);
System.Console.WriteLine(b);
The output is false, this method Equals is not working. How can we know that the value represented by obj is 0?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list