Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the assignment operator in C #

Shulou Source: shulou.com Published: 2022-06-01 02:06:36 09月21日 Update

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

Example

Take a look at the following example to see all the assignment operators available in C#:

Using System

Namespace OperatorsAppl

{

Class Program

{

Static void Main (string [] args)

{

Int a = 21

Int c

C = a

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

C + = a

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

C-= a

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

C * = a

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

C / = a

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

C = 200

C% = a

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

C = 2

Console.WriteLine (value of "Line 8-> > = c = {0}", c)

C & = 2

Console.WriteLine (value of "Line 9-& = c = {0}", c)

C ^ = 2

Console.WriteLine (value of "Line 10-^ = c = {0}", c)

C | = 2

Console.WriteLine (value of "Line 11-| = c = {0}", c)

Console.ReadLine ()

}

}

}

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

Line 1-= c value = 21Line 2-+ = c value = 42Line 3-- = c value = 21Line 4-* = c value = 441Line 5-/ = c value = 21Line 6 -% = c value = 11Line 7-= c value = 11Line 9-& = c value = 2Line 10-^ = c value = 0Line 11-| = c value = 2, the study on "how to use assignment operators in C #" ends I hope I can solve everyone's 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!

Tags: Operators examples operations learning examples more face-to-face help practical next code articles methods theories knowledge articles results websites please see materials Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Redmi Shulou Information Shulou Technology Huawei