Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the arithmetic operator of C #

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use the arithmetic operator of C#". In the daily operation, I believe that many people have doubts about how to use the arithmetic operator of C#. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt about how to use the arithmetic operator of C#! Next, please follow the editor to study!

Example

Take a look at the following example for all the arithmetic operators available in C#:

Using System

Namespace OperatorsAppl

{

Class Program

{

Static void Main (string [] args)

{

Int a = 21

Int b = 10

Int c

C = a + b

Console.WriteLine (value of "Line 1-c is {0}", c)

C = a-b

Console.WriteLine (the value of "Line 2-c is {0}", c)

C = a * b

Console.WriteLine (the value of "Line 3-c is {0}", c)

C = a / b

Console.WriteLine (value of "Line 4-c is {0}", c)

C = a% b

Console.WriteLine (the value of "Line 5-c is {0}", c)

/ / + + a perform self-increment operation first and then assign values

C = + + a

Console.WriteLine (value of "Line 6-c is {0}", c)

/ / the value of an at this time is 22

/ /-- a perform self-subtraction before assigning values

C =-- a

Console.WriteLine (the value of "Line 7-c is {0}", c)

Console.ReadLine ()

}

}

}

When the above code is compiled and executed, it produces the following results:

The value of Line 1-c is 31Line 2-c, the value of 11Line 3-c is the value of 210Line 4-c, the value of 2Line 5-c is the value of 1Line 6-c, the value of 22Line 7-c is 21.

C = an increment: first assign a to c, and then perform a self-increment operation on a.

C = + + a: first perform a self-increment operation, and then assign a to c.

C = a Murray: first assign a to c, then perform a self-subtraction operation on a.

C =-- a: first self-subtract a, and then assign a to c.

At this point, the study of "how to use the arithmetic operator of C #" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report